Class: AuthController

Inherits:
ApplicationController show all
Defined in:
app/controllers/auth_controller.rb

Overview

This class has authentication methods that will generate a JWT for the client to hold

Author:

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_user

Instance Method Summary (collapse)

Instance Method Details

- (Object) authenticate



6
7
8
9
10
11
12
13
# File 'app/controllers/auth_controller.rb', line 6

def authenticate
  user = User.find_by_credentials(params[:email], params[:password])
  if user
    render json: authentication_payload(user)
  else
    render json: { errors: ['Invalid email or password'] }, status: :unauthorized
  end
end