blob: 2f4285289236e9c9ddd93af56662bfd84a37e33a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# frozen_string_literal: true
module Api
class AuthenticationsController
# The logic for the create method of AuthenticationsController.
class CreateLogic
include TokenGenerationConcern
def initialize(params)
@email = params[:email]
@password = params[:password]
@user_account = UserAccount.find_by(email: @email)
end
def call
return unless @user_account&.authenticate(@password)
generate_user_session_key
generate_token
end
private
def service_params
{ email: @email, role: @user_account.role, session_key: @user_account.session_key }
end
end
end
end
|