9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/booth/userland/registrations/create.rb', line 9
def call
request.must_be_post!
debug { "You want to register the username #{username_param.inspect}, let's see if it is taken." }
finding = ::Booth::Credentials::FindByUsername.call(username: username_param)
registration_storage.username = finding.normalized_invalid_username
finding.on_success do
debug { 'That username is taken. You should try to login instead.' }
login_storage.credential_for_username = finding.credential
public_message = I18n.t('booth.username_already_exists')
return Tron.success :username_exists, public_message:
end
debug { 'That username is available.' }
return finding unless finding.failure == :credential_not_found
creation = ::Booth::Credentials::CreateWithOnboarding.call(
username: finding.normalized_username,
allowed_modes:,
scope:
)
creation.on_success do
::Booth::Sessions::CreateAndLogin.call(credential: creation.credential, request:)
return Tron.success :username_is_available, public_message: 'You have registered an account.'
end
Tron.failure :registration_failed, error: creation.error
end
|