Sha256: ad8912a41fdbe8a61da8f72e60ec8c8bad51f7a36d4b580a9217f90ab33465a0

Contents?: true

Size: 684 Bytes

Versions: 3

Compression:

Stored size: 684 Bytes

Contents

module Ctws
  class AuthenticationController < CtwsController
    skip_before_action :authorize_request, only: :authenticate
    
    # return auth token once user is authenticated
    def authenticate
      auth_token = Ctws::AuthenticateUser.new(auth_params[:email], auth_params[:password]).call
      json_response auth_as_jsonapi(auth_token)
      
    end
    
    private
    
    def auth_as_jsonapi auth_token
      {
        type: controller_name,
        attributes: {
          message: Ctws::Message.authenticated_user_success, 
          auth_token: auth_token, 
        }
      }
    end
    
    def auth_params
      params.permit(:email, :password)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ctws-0.1.7.alpha app/controllers/ctws/authentication_controller.rb
ctws-0.1.6.alpha app/controllers/ctws/authentication_controller.rb
ctws-0.1.5.alpha app/controllers/ctws/authentication_controller.rb