Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Api
- module V1
- class Auth::AuthenticationController < ApplicationController
- skip_before_action :authorize_request, only: :authenticate
- skip_before_action :authorize_sitter_request, only: :sitterauthenticate
- def authenticate
- guardian_auth_token = Api::V1::Auth::Guardsec::AuthenticateGuardian.new(auth_params[:userInput], auth_params[:password]).call
- guardian = Guardian.where('username LIKE :userInput OR email LIKE :userInput OR mobile LIKE :userInput', userInput: "%#{auth_params[:userInput]}%")
- guardianSerial = Guardian.find_by(id: guardian.ids)
- response = {
- data: {
- message: AuthMessages.logged_in,
- guardian_auth_token: guardian_auth_token,
- guardian: GuardianSerializer.new(guardianSerial)
- }
- }
- json_response(response, :logged_in)
- end
- private
- def auth_params
- params.permit(:userInput, :password)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement