Last modified by SuperUwe Trueggelmann on 2025-06-03

Hide last authors
SuperUwe Trueggelmann 1.1 1 {{groovy}}
2
3 import groovy.sql.Sql
4
5 String strDBTable = "\"regUser\".\"newUser\""
6 String strFormStatus = ""
7 String strEmailBody = ""
8 String strEmail = ""
9 String strUID = ""
SuperUwe Trueggelmann 1.2 10 def sqlConnection = new Sql(services.cmpConnectDB.connectRegDB())
SuperUwe Trueggelmann 1.1 11
12 String strReqEm = request.em ?: "missing"
13 String strReqCc = request.cc ?: "missing"
14
15 String strConfEmail = services.cleanStr.alphanum(strReqEm)
16 String strConfCode = services.cleanStr.alphanum(strReqCc)
17
18 if ((strConfEmail != "missing") && (strConfCode != "missing")){
19 String sqlHowManyRecords = "SELECT count(createtime) as reccount FROM " + strDBTable + " where email='" + strConfEmail + "' and confemailsentcode='" + strConfCode + "'"
20 def intRecCount = sqlConnection.rows(sqlHowManyRecords).reccount[0] ?:0
21 if (intRecCount > 0){
22 String sqlQueryTimeSince = "SELECT (EXTRACT(EPOCH from (SELECT now()-createtime as timesince FROM " + strDBTable + " where email='" + strConfEmail + "' and confemailsentcode='" + strConfCode + "')))::int as secsince"
23 def objTimeSince = sqlConnection.rows(sqlQueryTimeSince).secsince[0] ?: "not found"
24 Long lngTimeSince = Long.valueOf(objTimeSince) ?: 9999999
25 if (objTimeSince == "not found"){
26 println "This was not a valid link!"
27 }
28 else{
29 if (lngTimeSince < 86400){
30 strIP = request.remoteAddr
31 String sqlQueryUpdateUserStatus = "UPDATE " + strDBTable +
32 """
33 SET
34 confreceivecode = '$strConfCode',
35 confreceivetime = now(),
36 confreceiveip = '$strIP'
37 WHERE email = '""" + strConfEmail + "' and confemailsentcode='" + strConfCode + "';"
38 sqlConnection.execute(sqlQueryUpdateUserStatus)
39 String sqlQueryGetUserInfo = """SELECT uid, prefname, createtime, createip FROM ${strDBTable} WHERE email = '${strConfEmail}' and confemailsentcode='${strConfCode}';"""
40 def objCurRec = sqlConnection.firstRow(sqlQueryGetUserInfo)
41 strUID = objCurRec.uid ?:"0"
42 strPrefname = objCurRec.prefname ?:"DefaultName"
43 strCreatetime = objCurRec.createtime ?:"DefaultTime"
44 strCreateip = objCurRec.createip ?:"DefaultIP"
45
46 strEmailBody = "Dear " + strPrefname + ","
47 strEmailBody = strEmailBody + "\r\n" + "\r\n" + "You have successfully confirmed your e-mail address!" + "\r\n" + "\r\n"
48 strEmailBody = strEmailBody + "Your request to participate in the CEC Scheme will now be reviewed by the CEC Administration and Mastercard and you will be informed about the decision." + "\r\n" + "\r\n"
49 strEmailBody = strEmailBody + "Please allow us up to 10 working days for processing your application." + "\r\n" + "\r\n"
50 strEmailBody = strEmailBody + "In the meantime, while you are waiting for your application to be approved, may we suggest you download the form for the CEC NDA from the following location: https://cecocert.com/bin/view/StartPage/X1200%20-%20CEC%20NDA%20Download/WebHome?" + "\r\n"
51 strEmailBody = strEmailBody + "Please follow the instructions on the Download page, and once completed, e-mail the CEC NDA to contact@cecocert.com. Thank you!" + "\r\n" + "\r\n"
52 strEmailBody = strEmailBody + "The CEC Administration" + "\r\n" + "\r\n" + "\r\n" + "\r\n"
53 strEmailBody = strEmailBody + "DebugInfo:" + strUID + "|" + strConfEmail + "|" + strCreatetime + "|" + strCreateip
54 strFormStatus = "SendEmail"
55 def listAttachments = []
56 xcontext.put("strEmail",strConfEmail)
57 xcontext.put("strEmailBody",strEmailBody)
58 xcontext.put("strPrefname",strPrefname)
59 xcontext.put("listAttachments",listAttachments)
60 }
61 else{
62 println "I am sorry, but this e-mail confirmation link has expired. Please register again!"
63 }
64 }
65 }
66 else{
67 println "This was not a valid link!"
68 }
69 sqlConnection.close()
70 xcontext.put("strFormStatus",strFormStatus)
71 }
72
73
74
75 {{/groovy}}
76 {{velocity}}
77 ##$xcontext.strFormStatus
78 #if( $xcontext.strFormStatus == "SendEmail" )
79 #set($email_to = "${xcontext.strEmail}")
80 #set($email_subject = "CEC Registration - E-mail address successfully confirmed")
81 #set($email_from = "cec_noreply@cecocert.com")
82 #set($email_text = "$xcontext.strEmailBody")
83 #set ($message = $services.mail.sender.createMessage($email_from, $email_to, $email_subject))
84 #set ($discard = $message.addPart("text/plain", ${xcontext.strEmailBody}))
85 ##set ($discard = $message.addPart("attachments", ${xcontext.listAttachments}))
86 #set ($mailResult = $services.mail.sender.send($message))
87 ## Check if the message was created properly and if we have permissions to send emails
88 #if ($services.mail.sender.lastError)
89 {{error}}$exceptiontool.getStackTrace($services.mail.sender.lastError){{/error}}
90 #end
91 ## Check if the mail we tried to send has failed to be sent
92 #set ($statuses = $mailResult.statusResult.getAllErrors())
93 #if ($statuses.hasNext())
94 #set ($status = $statuses.next())
95 {{error}}
96 Error: $status.errorSummary ($status.state)
97 $status.errorDescription
98 {{/error}}
99 #end
100 ${xcontext.strPrefname}, you have successfully confirmed your e-mail address!
101 An e-mail confirming this was sent to your e-mail address ${xcontext.strEmail}.
102 CEC Administration will now review your application to participate in the CEC Scheme with Mastercard and will inform you of the outcome.
103 Please allow up to 10 working days for this process.
104 #end
105
106 {{/velocity}}