Module: AuthRails::Authentication

Extended by:
ActiveSupport::Concern
Included in:
ApiController
Defined in:
app/controllers/concerns/auth_rails/authentication.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_user!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/concerns/auth_rails/authentication.rb', line 7

def authenticate_user!
  payload = Services::JwtService.verify_token(
    token: lookup_access_token,
    secret_key: Configuration::Jwt::AccessToken.secret_key
  )

  CurrentAuth.user = AuthRails.retrieve_resource(
    params: {
      AuthRails.identifier_name => payload[:sub]
    }
  )

  raise AuthRails.error_class, :unauthenticated unless CurrentAuth.user
end