blob: fd1607943b6c09bbb2a5a12ea9da8dc212307a4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# frozen_string_literal: true
module Api
# The controller to generate new tokens.
class RefreshTokensController < AuthenticatedController
before_action :validate_jwt
def create
@current_user_account.update_attribute(:session_key, SecureRandom.hex(16))
@token = service.call(authentication_token[0]['exp'])
render json: @token, status: :ok
end
def service_params
{ email: @current_user_account.email, role: @current_user_account.role }
end
def service
@service ||= Services::TokenGenerationService.new(service_params)
end
end
end
|