Sha256: 3ce6bbe5db30893cb98ae31971d3df465c549a76365513da821f42758b699733

Contents?: true

Size: 660 Bytes

Versions: 5

Compression:

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

5 entries across 5 versions & 1 rubygems

Version Path
ctws-0.2.3.beta app/controllers/ctws/authentication_controller.rb
ctws-0.2.2.beta app/controllers/ctws/authentication_controller.rb
ctws-0.2.1.beta app/controllers/ctws/authentication_controller.rb
ctws-0.2.0.beta app/controllers/ctws/authentication_controller.rb
ctws-0.1.14.beta app/controllers/ctws/authentication_controller.rb