Class: AuthRails::Api::AuthController
- Inherits:
-
AuthRails::ApiController
- Object
- ActionController::API
- AuthRails::ApiController
- AuthRails::Api::AuthController
- Defined in:
- app/controllers/auth_rails/api/auth_controller.rb
Instance Method Summary collapse
Methods included from AuthRails::Authentication
Instance Method Details
#create ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/controllers/auth_rails/api/auth_controller.rb', line 6 def create resource = AuthRails.retrieve_resource(params: params) raise AuthRails.error_class, :unauthenticated if resource.blank? || !AuthRails.authenticate(resource: resource, password: params[:password]) respond_to_create(generate_token(resource)) end |
#refresh ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/auth_rails/api/auth_controller.rb', line 14 def refresh decoded_payload = Services::JwtService.verify_token( token: lookup_refresh_token, algorithm: Configuration::Jwt::RefreshToken.algorithm, secret_key: Configuration::Jwt::RefreshToken.secret_key ) resource = AuthRails.jwt_strategy.retrieve_resource(payload: decoded_payload) raise AuthRails.error_class, :unauthenticated if resource.blank? resource.allowed_tokens.find_by( jti: decoded_payload[:jti], aud: decoded_payload[:aud] )&.destroy! respond_to_refresh(generate_token(resource)) end |