ToolJet/app/controllers/authentication_controller.rb

16 lines
502 B
Ruby
Raw Normal View History

2021-03-31 16:18:42 +00:00
class AuthenticationController < ApplicationController
2021-04-29 06:41:23 +00:00
skip_before_action :authenticate_request
def authenticate
command = AuthenticateUser.call(params[:email], params[:password])
if command.success?
user = User.find_by_email params[:email]
render json: { auth_token: command.result, first_name: user.first_name, last_name: user.last_name,
email: user.email }
else
render json: { error: command.errors }, status: :unauthorized
2021-03-31 16:18:42 +00:00
end
2021-04-29 06:41:23 +00:00
end
2021-03-31 16:18:42 +00:00
end