Class: Gaku::Api::AuthenticateUser
- Inherits:
-
Object
- Object
- Gaku::Api::AuthenticateUser
- Includes:
- SimpleCommand
- Defined in:
- app/services/gaku/api/authenticate_user.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(username:, password:) ⇒ AuthenticateUser
constructor
A new instance of AuthenticateUser.
Constructor Details
#initialize(username:, password:) ⇒ AuthenticateUser
Returns a new instance of AuthenticateUser.
9 10 11 12 |
# File 'app/services/gaku/api/authenticate_user.rb', line 9 def initialize(username:, password:) @username = username @password = password end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'app/services/gaku/api/authenticate_user.rb', line 7 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'app/services/gaku/api/authenticate_user.rb', line 7 def username @username end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/gaku/api/authenticate_user.rb', line 14 def call if user secret = SecureRandom.hex(64) $redis.set("token:#{jti}", secret, ex: 20.minutes) { auth_token: JsonWebToken.encode({user_id: user.id}, exp: 3.minutes.from_now, jti: jti, secret: secret), refresh_token: JsonWebToken.encode({user_id: user.id}, exp: 20.minutes.from_now, jti: jti, secret: secret) } end end |