Skip to content

Instantly share code, notes, and snippets.

@ikhsanalatsary
Last active November 21, 2018 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikhsanalatsary/5b95765c0f21badec9d78c57cbf7241b to your computer and use it in GitHub Desktop.
Save ikhsanalatsary/5b95765c0f21badec9d78c57cbf7241b to your computer and use it in GitHub Desktop.
rails action
def auth
user = User.find_by(username: params[:username])
if user&.check_password(params[:password])
render json: user
else
render json: { errors: ['wrong username or password'] }, status: :unauthorized
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment