Sha256: 95248cc536c4a349ff30a0757f8bb661008d52f56fe5a9a56fba73b0b5762afc

Contents?: true

Size: 686 Bytes

Versions: 6

Compression:

Stored size: 686 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

6 entries across 6 versions & 1 rubygems

Version Path
ctws-0.1.13.alpha app/controllers/ctws/authentication_controller.rb
ctws-0.1.12.alpha app/controllers/ctws/authentication_controller.rb
ctws-0.1.11.alpha app/controllers/ctws/authentication_controller.rb
ctws-0.1.10.alpha app/controllers/ctws/authentication_controller.rb
ctws-0.1.9.alpha app/controllers/ctws/authentication_controller.rb
ctws-0.1.8.alpha app/controllers/ctws/authentication_controller.rb