api integrated

This commit is contained in:
Min Zeya Phyo
2017-04-19 19:39:58 +06:30
parent c4e76c53b2
commit 0a97947259
25 changed files with 755 additions and 2 deletions

View 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