2018-02-16 15:02:03 +00:00
|
|
|
class AuthenticationController < ApplicationController
|
|
|
|
|
skip_before_action :authorize_request, only: :authenticate
|
|
|
|
|
|
|
|
|
|
def authenticate
|
|
|
|
|
auth_token =
|
|
|
|
|
AuthenticateUser.new(auth_params[:email], auth_params[:password]).call
|
2018-02-19 16:03:07 +00:00
|
|
|
user = User.find_by(email: auth_params[:email])
|
2020-04-24 17:10:55 +02:00
|
|
|
|
|
|
|
|
response = user.as_json
|
|
|
|
|
response[:auth_token] = auth_token
|
|
|
|
|
json_response(response)
|
2018-02-16 15:02:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def auth_params
|
|
|
|
|
params.permit(:email, :password)
|
|
|
|
|
end
|
|
|
|
|
end
|