0 Stimmen

Änderungen von Dokument Benutzername vergessen?

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

Von 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]
Auf Version 5.1
bearbeitet von xwikiadmin
am 2022/07/28 11:40
Änderungskommentar: Install extension [org.xwiki.platform:xwiki-platform-administration-ui/13.10.8]

Zusammenfassung

Details

Seiteneigenschaften
Inhalt
... ... @@ -1,85 +1,5 @@
1 1  {{velocity}}
2 -#set($email = "$!request.get('e')")
3 -#if($email == '' || !$services.csrf.isTokenValid($request.form_token))
4 -{{translation key="xe.admin.forgotUsername.instructions"/}}
5 -
6 -{{html}}
7 - <form method="post" action="$doc.getURL()" class="xformInline">
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>
16 - </form>
17 -{{/html}}
18 -
19 -#else
20 - #set($query = $services.query.hql(", BaseObject obj, StringProperty prop where obj.name = doc.fullName and obj.className = 'XWiki.XWikiUsers' and prop.id.id = obj.id and prop.id.name = 'email' and LOWER(prop.value) = :email").bindValue('email', $email.toLowerCase()))
21 - #set($results = $query.execute())
22 - ## If local user does not exist check global user
23 - #if($results.size() == 0 && ${xcontext.database} != ${xcontext.mainWikiName})
24 - #set($results = $query.setWiki("${xcontext.mainWikiName}").execute())
25 - #end
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)
40 -
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}}
49 -
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
69 - #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"])
75 -
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
84 -#end
2 +#set ($newUrl = $services.security.authentication.getAuthenticationURL('retrieveusername', $request.parameterMap))
3 +#set ($discard = $services.logging.deprecate("ForgotUsername", "The page [XWiki.ForgotUsername] should not be used anymore in favor of the new 'authenticate/retrieveusername' URL."));
4 +#set ($discard = $response.sendRedirect($newUrl))
85 85  {{/velocity}}
Powered by MakerspaceBonn e.V.