1
+ Flow org.gluu.agama.magiclink
2
+ Basepath ""
3
+ Timeout 360 seconds
4
+ Configs conf
5
+ // Create and initialize variable to receive email input
6
+ emailObj = {errorMessage: ""}
7
+ // Iterate x times max
8
+ Repeat 3 times max
9
+ // Retrieve user email address from UI
10
+ formDataInput = RRF "mailform.ftlh" emailObj
11
+ // Assign user email input to a variable
12
+ email = formDataInput.mail
13
+ // Create an instance of MagicLinkService with configurable parameters.
14
+ magicLinkService = Call org.gluu.agama.jans.MagicLinkService#getInstance conf.hostName conf.secretKey conf.tokenExpiration
15
+ // Get user details using magic link service
16
+ userData = Call magicLinkService getUserEntity email
17
+ // User data
18
+ Log "@info User data is : "
19
+ When userData.empty is not true
20
+ // User found
21
+ Log "@info User found with e-mail % " email
22
+ // Call magic link service to send mail
23
+ token = Call magicLinkService sendMail email
24
+ // Magic link has been sent
25
+ Log "@debug Mail has been sent with token %" token
26
+ // Empty object assign
27
+ obj = {}
28
+ // Fetching magic-link data
29
+ data = RRF "acknowledgement.ftlh" obj true
30
+ // Token was
31
+ Log "@info Token was : %" data.token
32
+ // Token verification
33
+ isVerify = Call magicLinkService verifyMagicLink data.token
34
+ // Is Token verified
35
+ When isVerify is true
36
+ // Token verification success
37
+ Log "@info Token verification successful"
38
+ // Flow finished successfully
39
+ Finish userData.uid
40
+ Otherwise
41
+ // Token verification failed
42
+ Log "@info Token verification failed"
43
+ // Token verification failed
44
+ it_mymhg = {success:false, error: "Token verification failed"}
45
+ Finish it_mymhg
46
+ Otherwise
47
+ // User not found
48
+ Log "@info User not found with mail %" email
49
+ // Error message user not found
50
+ emailObj.errorMessage = "User Not found"
51
+ // Max attempts Reached
52
+ Log "@info Max attempts reached"
53
+ // Flow finish with an error
54
+ it_ikqan = {success:false, error: "Max attempts reached"}
55
+ Finish it_ikqan
0 commit comments