Class: Monban::Domain::Auth::Authorized

Inherits:
Object
  • Object
show all
Includes:
Getto::InitializeWith
Defined in:
lib/monban/domain/auth.rb

Instance Method Summary collapse

Instance Method Details

#decode(token) ⇒ Object



246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/monban/domain/auth.rb', line 246

def decode(token)
  ::JWT.decode(
    token,
    authorized_secret,
    true,
    {
      algorithm: authorized_algorithm,
    }
  ).first
rescue ::JWT::DecodeError => e
  error! e.message
end

#encode(account) ⇒ Object



259
260
261
262
263
264
265
# File 'lib/monban/domain/auth.rb', line 259

def encode()
  ::JWT.encode(
    ,
    authorized_secret,
    authorized_algorithm
  )
end

#error!(message) ⇒ Object

Raises:



267
268
269
# File 'lib/monban/domain/auth.rb', line 267

def error!(message)
  raise DecodeError, message
end