api integrated
This commit is contained in:
33
app/controllers/concerns/login_verification.rb
Normal file
33
app/controllers/concerns/login_verification.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
module LoginVerification
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :authenticate
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
authenticate_session_token || render_unauthorized
|
||||
end
|
||||
|
||||
def authenticate_session_token
|
||||
token = session[:session_token]
|
||||
if (token)
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def render_unauthorized()
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user