Last active
March 6, 2016 12:46
-
-
Save tbuehlmann/6feb7a486d576a362b7e to your computer and use it in GitHub Desktop.
login error message/alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def authenticate | |
if params[:username].present? && params[:password].present? | |
inn = Inn.find_by(username: params[:username]) | |
if inn | |
authenticated = inn.authenticate(params[:password]) | |
if authenticated | |
redirect_to inns_url, notice: 'You are now logged in.' | |
return | |
else | |
flash[:notice] = 'Wrong password. Please try again.' | |
end | |
else | |
flash[:notice] = 'No username found. Please try again.' | |
end | |
else | |
flash[:notice] = 'Fields cannot be blank. Please input both username and password.' | |
end | |
render 'login' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment