0 Stimmen

Änderungen von Dokument Benutzername vergessen?

Zuletzt geändert von xwikiadmin am 2022/07/28 11:40

Von Version 1.1
bearbeitet von xwikiadmin
am 2020/06/24 19:59
Änderungskommentar: Install extension [org.xwiki.platform:xwiki-platform-administration-ui/12.4]
Auf Version 2.1
bearbeitet von xwikiadmin
am 2021/07/06 21:14
Änderungskommentar: Install extension [org.xwiki.platform:xwiki-platform-administration-ui/12.10.8]

Zusammenfassung

Details

Seiteneigenschaften
Inhalt
... ... @@ -1,11 +1,18 @@
1 1  {{velocity}}
2 2  #set($email = "$!request.get('e')")
3 -#if($email == '')
3 +#if($email == '' || !$services.csrf.isTokenValid($request.form_token))
4 4  {{translation key="xe.admin.forgotUsername.instructions"/}}
5 5  
6 6  {{html}}
7 7   <form method="post" action="$doc.getURL()" class="xformInline">
8 - <div><label for="e">$services.localization.render('xe.admin.forgotUsername.email.label')</label> <input type="text" id="e" name="e"/> <span class="buttonwrapper"><input type="submit" value="$services.localization.render('xe.admin.forgotUsername.submit')" class="button"/></span></div>
8 + <div>
9 + <label for="e">$services.localization.render('xe.admin.forgotUsername.email.label')</label>
10 + <input type="text" id="e" name="e"/>
11 + <input type="hidden" name="form_token" value="$services.csrf.getToken()"/>
12 + <span class="buttonwrapper">
13 + <input type="submit" value="$services.localization.render('xe.admin.forgotUsername.submit')" class="button"/>
14 + </span>
15 + </div>
9 9   </form>
10 10  {{/html}}
11 11  
... ... @@ -16,21 +16,63 @@
16 16   #if($results.size() == 0 && ${xcontext.database} != ${xcontext.mainWikiName})
17 17   #set($results = $query.setWiki("${xcontext.mainWikiName}").execute())
18 18   #end
19 - #if($results.size() == 0)
20 - {{translation key="xe.admin.forgotUsername.error.noAccount"/}}
26 + #set ($emailError = false)
27 + #if($results.size() != 0)
28 + ## Send the email
29 + #set ($from = $services.mail.sender.configuration.fromAddress)
30 + #if ("$!from" == '')
31 + #set ($from = "no-reply@${request.serverName}")
32 + #end
33 + ## The mail template use $usernames to display the results.
34 + #set ($usernames = $results)
35 + #set ($mailTemplateReference = $services.model.createDocumentReference('', 'XWiki', 'ForgotUsernameMailContent'))
36 + #set ($mailParameters = {'from' : $from, 'to' : $email, 'language' : $xcontext.locale})
37 + #set ($message = $services.mail.sender.createMessage('template', $mailTemplateReference, $mailParameters))
38 + #set ($discard = $message.setType('Forgot Username'))
39 + #macro (displayError $text)
21 21  
22 - [[{{translation key="xe.admin.forgotUsername.error.retry"/}}>>$doc.fullName]] | [[{{translation key="xe.admin.forgotUsername.login"/}}>>path:${xwiki.getURL('XWiki.XWikiLogin', 'login')}]]
23 - #elseif($results.size() == 1)
24 - $services.localization.render('xe.admin.forgotUsername.result', ["**${results.get(0).substring($results.get(0).indexOf('.')).substring(1)}**"])
41 + {{html}}
42 + <div class="xwikirenderingerror" title="Click to get more details about the error" style="cursor: pointer;">
43 + $services.localization.render('xe.admin.forgotUsername.error.emailFailed')
44 + </div>
45 + <div class="xwikirenderingerrordescription hidden">
46 + <pre>${text}</pre>
47 + </div>
48 + {{/html}}
25 25  
26 - [[{{translation key="xe.admin.forgotUsername.login"/}}>>path:${xwiki.getURL('XWiki.XWikiLogin', 'login')}]]
27 - #else
28 - {{translation key="xe.admin.forgotUsername.multipleResults"/}}
29 - #foreach($item in $results)
30 - * **${item.substring($item.indexOf('.')).substring(1)}**
50 + #set ($emailError = true)
51 + #end
52 + ## Check for an error constructing the message!
53 + #if ($services.mail.sender.lastError)
54 + #displayError($exceptiontool.getStackTrace($services.mail.sender.lastError))
55 + #else
56 + ## Send the message and wait for it to be sent or for any error to be raised.
57 + #set ($mailResult = $services.mail.sender.send([$message], 'database'))
58 + ## Check for errors during the send
59 + #if ($services.mail.sender.lastError)
60 + #displayError($exceptiontool.getStackTrace($services.mail.sender.lastError))
61 + #else
62 + #set ($failedMailStatuses = $mailResult.statusResult.getAllErrors())
63 + #if ($failedMailStatuses.hasNext())
64 + #set ($mailStatus = $failedMailStatuses.next())
65 + #displayError($mailStatus.errorDescription)
66 + #end
67 + #end
68 + #end
31 31   #end
70 + ## We always display a success message even if there's no user found to avoid disclosing information
71 + ## about the users registered on the wiki.
72 + #if (!$emailError)
73 + {{success}}
74 + $services.localization.render('xe.admin.forgotUsername.emailSent', ["$email"])
32 32  
33 - [[{{translation key="xe.admin.forgotUsername.login"/}}>>path:${xwiki.getURL('XWiki.XWikiLogin', 'login')}]]
34 - #end
76 + {{html}}
77 + <div>
78 + <a href="$xwiki.getURL('XWiki.XWikiLogin', 'login', 'loginLink=1')">$services.localization.render('xe.admin.forgotUsername.login')</a>
79 + </div>
80 + {{/html}}
81 +
82 + {{/success}}
83 + #end
35 35  #end
36 36  {{/velocity}}
Powered by MakerspaceBonn e.V.