- 1
- 2
- 3
- 4
- 5

0 Votes

# Wiki-Quellcode von Benutzername vergessen?

Zuletzt geändert von wiki admin am 2021/11/22 20:38
Exportieren
Office Formate
Als PDF exportieren Als ODT exportieren Als RTF exportieren
Andere Formate
Als HTML exportieren

Verstecke letzte Bearbeiter

author | version | line-number | content
--- | --- | --- | ---
| 1.1 | 1 | {{velocity}}
|  | 2 | #set($email = "$!request.get('e')")
| 2.1 | 3 | #if($email == '' || !$services.csrf.isTokenValid($request.form_token))
| 1.1 | 4 | {{translation key="xe.admin.forgotUsername.instructions"/}}
|  | 5 |
|  | 6 | {{html}}
|  | 7 | <form method="post" action="$doc.getURL()" class="xformInline">
| 2.1 | 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>
| 1.1 | 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
| 2.1 | 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)
| 1.1 | 40 |
| 2.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}}
| 1.1 | 49 |
| 2.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
| 1.1 | 69 | #end
| 2.1 | 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"])
| 1.1 | 75 |
| 2.1 | 76 | {{html}}
|  | 77 | <div>
| 3.1 | 78 | <a href="$xwiki.getURL('XWiki.XWikiLogin', 'login', 'loginLink=1')">$services.localization.render('xe.admin.forgotUsername.login')</a>
| 2.1 | 79 | </div>
|  | 80 | {{/html}}
|  | 81 |
|  | 82 | {{/success}}
|  | 83 | #end
| 1.1 | 84 | #end
|  | 85 | {{/velocity}}

© 2019-2021 klode.tech | Alle Rechte vorbehalten.
XWiki 12.10.10