Class: ForestLiana::Token

Inherits:
Object
  • Object
show all
Defined in:
app/services/forest_liana/token.rb

Constant Summary collapse

/forest_session_token=([^;]*)/

Class Method Summary collapse

Class Method Details

.create_token(user, rendering_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/forest_liana/token.rb', line 15

def self.create_token(user, rendering_id)
  return JWT.encode({
    id: user['id'],
    email: user['email'],
    first_name: user['first_name'],
    last_name: user['last_name'],
    team: user['teams'][0],
    role: user['role'],
    tags: user['tags'],
    rendering_id: rendering_id,
    exp: expiration_in_seconds(),
    permission_level: user['permission_level'],
  }, ForestLiana.auth_secret, 'HS256')
end

.expiration_in_daysObject



7
8
9
# File 'app/services/forest_liana/token.rb', line 7

def self.expiration_in_days
  Time.current + EXPIRATION_IN_SECONDS
end

.expiration_in_secondsObject



11
12
13
# File 'app/services/forest_liana/token.rb', line 11

def self.expiration_in_seconds
  return Time.now.to_i + EXPIRATION_IN_SECONDS
end