blob: b1bc10abfbdf9841a8ebe7cb8b7d0822b9b0b893 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# frozen_string_literal: true
module Services
# The service responsible for JWT generation.
class TokenGenerationService
def initialize(params)
@email = params[:email]
@role = params[:role]
end
def call(expiration)
JWT.encode(payload.merge({ exp: expiration.to_i }), ENV['HMAC_SECRET_KEY'], 'HS512')
end
private
def payload
{ data: @email, aud: @role }
end
end
end
|