Class: Pusher::PushNotifications::UseCases::GenerateToken
- Inherits:
-
Object
- Object
- Pusher::PushNotifications::UseCases::GenerateToken
- Defined in:
- lib/pusher/push_notifications/use_cases/generate_token.rb
Defined Under Namespace
Classes: GenerateTokenError
Class Method Summary collapse
-
.generate_token(user:) ⇒ Object
Creates a signed JWT for a user id.
Class Method Details
.generate_token(user:) ⇒ Object
Creates a signed JWT for a user id.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pusher/push_notifications/use_cases/generate_token.rb', line 10 def self.generate_token(user:) raise GenerateTokenError, 'User Id cannot be empty.' if user.empty? if user.length > UserId::MAX_USER_ID_LENGTH raise GenerateTokenError, 'User id length too long ' \ "(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)" end jwt_token = PushNotifications::Token.new { 'token' => jwt_token.generate(user) } end |