-
Notifications
You must be signed in to change notification settings - Fork 7
/
org.gluu.agama.smtp.main.flow
71 lines (71 loc) · 3.89 KB
/
org.gluu.agama.smtp.main.flow
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Authn Techniques that rely on sending email
Flow org.gluu.agama.smtp.main
Basepath ""
Timeout 360 seconds
Configs conf
Inputs emailHint
// Create and initialize variable to receive email input
emailObj = { email: emailHint, captureLocation: conf.captureLocation, errorMessage: "" }
// Iterate x times max
max = Repeat 3 times max
// Retrieve user email address from UI
uiInput = RRF "main.ftlh" emailObj
// Assign user email input to a variable
email = uiInput.email
// Create an instance Email Service
emailService = Call org.gluu.agama.smtp.EmailService#getInstance
// Get User Details using Email Service
userData = Call emailService getUserEntity email
// 1. Logic to determine if user email is already registered 2. Initialize location, timezone info from UI to user-data
emailUnknown = userData.empty
userData.context = { location: uiInput.location, timeZone: uiInput.zone, device: uiInput.device }
When emailUnknown is true
// Trigger sub-routine to verify email
emailVerificationResult = Trigger org.gluu.agama.smtp.emailVerification email false userData.context
// Reset error message to empty after email verification
emailObj.errorMessage = ""
// If email data is valid
When emailVerificationResult.success is true
// E-mail verification passed, initiating user provisioning flow
Log "@info E-mail verification passed, initiating user provisioning flow"
// Create object to register user with email input
emailObj = { email: email }
// Run sub-routine to register user with email input
registrationResult = Trigger org.gluu.agama.smtp.registration emailObj
// When user registration is successful
When registrationResult.success is true
// Assign registered user data to a object attributes
userData = registrationResult.data
userData.email = email
// Show acknowledgement UI page for successful registration
acknowledgementInput = RRF "acknowledgement.ftlh" userData
// User clicks in continue button
When acknowledgementInput.ack is "continue"
// Assign User Id (email) to a variable
uid = userData.uid
// Finish the flow successfully
it_dvowr = {success:true, data: { userId: uid, uid: uid}}
Finish it_dvowr
// When email verification is invalid
When emailVerificationResult.success is false
// Error variable assignment.
emailObj.errorMessage = "Error sending email. Check email address and SMTP configuration."
// User with same email already exists
Log "@info User with e-mail % is known" email
// Run email verification sub-routine
emailVerificationResult = Trigger org.gluu.agama.smtp.emailVerification email true userData.context
// When email verification is successful
When emailVerificationResult.success is true
// Assigning user id (email) to a variable
uid = userData.uid
// Email verification and hence authentication is successful
it_yjecp = {success:true, data: {userId: uid, uid: uid}}
Finish it_yjecp
When emailVerificationResult.success is false
// Assigning error message to a variable
emailObj.errorMessage = "Error sending email. Check email address and SMTP configuration."
// Fail if credential enrollment or authenticator flow failed
Log "@info Fail if credential enrollment or authenticator flow failed"
// Credential enrollment or authenticator flow failed
it_edgce = {success:false, error: "Credential enrollment or authenticator flow failed"}
Finish it_edgce