micro-blogger/app/controllers/v1/authentication_controller.rb

24 lines
552 B
Ruby
Raw Permalink Normal View History

2018-11-10 18:46:47 -06:00
# frozen_string_literal: true
module V1
class AuthenticationController < ApplicationController
skip_after_action :verify_authorized
skip_after_action :verify_policy_scoped
def authenticate
command = AuthenticateUser.new(auth_params)
@token = command.perform
@user = command.user
render "v1/authentication/authenticate" and return unless @token.nil?
render json: command.errors, status: :unauthorized
end
private
def auth_params
params.permit(:email, :password)
end
end
end