Advertisement
Guest User

Untitled

a guest
May 27th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. module Api
  2. module V1
  3. class Auth::AuthenticationController < ApplicationController
  4. skip_before_action :authorize_request, only: :authenticate
  5. skip_before_action :authorize_sitter_request, only: :sitterauthenticate
  6.  
  7. def authenticate
  8. guardian_auth_token = Api::V1::Auth::Guardsec::AuthenticateGuardian.new(auth_params[:userInput], auth_params[:password]).call
  9. guardian = Guardian.where('username LIKE :userInput OR email LIKE :userInput OR mobile LIKE :userInput', userInput: "%#{auth_params[:userInput]}%")
  10. guardianSerial = Guardian.find_by(id: guardian.ids)
  11.  
  12. response = {
  13. data: {
  14. message: AuthMessages.logged_in,
  15. guardian_auth_token: guardian_auth_token,
  16. guardian: GuardianSerializer.new(guardianSerial)
  17. }
  18. }
  19. json_response(response, :logged_in)
  20. end
  21.  
  22. private
  23.  
  24. def auth_params
  25. params.permit(:userInput, :password)
  26. end
  27. end
  28.  
  29. end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement