Skip to content

Instantly share code, notes, and snippets.

@tbuehlmann
Last active March 6, 2016 12:46
Show Gist options
  • Save tbuehlmann/6feb7a486d576a362b7e to your computer and use it in GitHub Desktop.
Save tbuehlmann/6feb7a486d576a362b7e to your computer and use it in GitHub Desktop.
login error message/alert
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