Last active
November 21, 2018 16:53
-
-
Save ikhsanalatsary/5b95765c0f21badec9d78c57cbf7241b to your computer and use it in GitHub Desktop.
rails action
This file contains 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 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