Class: Api::V2::AuthenticationController

Inherits:
ActionController::API
  • Object
show all
Includes:
ApiExceptionManagement
Defined in:
app/controllers/api/v2/authentication_controller.rb

Instance Method Summary collapse

Instance Method Details

#authenticateObject



4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/api/v2/authentication_controller.rb', line 4

def authenticate
    command = AuthenticateUser.call(params[:auth][:email], params[:auth][:password])
    
    if command.success?
        response.headers['Token'] = command.result
        render json: { message: ["Login successful!"] }
    else
        render json: { error: command.errors }, status: :unauthorized
    end
end