XWiki
ResetPassword
en
0
Main.WebHome
XWiki.Admin
XWiki.Admin
xwiki:XWiki.Admin
1219710939000
1228221475000
1228221475000
1.1

# $msg.get("xe.admin.passwordReset.title")

Imported from XAR
false
xwiki/2.1
false
XWiki.XWikiRights
1
0
select
allow
allow
4
Allow/Deny
0
com.xpn.xwiki.objects.classes.BooleanClass
0
0
select
1
groups
1
Groups
0
5
0
1
com.xpn.xwiki.objects.classes.GroupsClass
0
0
select
1
levels
2
Levels
0
3
0
com.xpn.xwiki.objects.classes.LevelsClass
0
0
select
1
users
3
Users
0
5
0
1
com.xpn.xwiki.objects.classes.UsersClass
XWiki.ResetPassword
0
XWiki.XWikiRights
8a0e8611-2818-4181-a8e9-1d1623ac3e77
0 XWiki.XWikiAllGroup edit XWiki.XWikiGuest
XWiki.XWikiRights
1
0
select
allow
allow
4
Allow/Deny
0
com.xpn.xwiki.objects.classes.BooleanClass
0
0
select
1
groups
1
Groups
0
5
0
1
com.xpn.xwiki.objects.classes.GroupsClass
0
0
select
1
levels
2
Levels
0
3
0
com.xpn.xwiki.objects.classes.LevelsClass
0
0
select
1
users
3
Users
0
5
0
1
com.xpn.xwiki.objects.classes.UsersClass
XWiki.ResetPassword
1
XWiki.XWikiRights
bb00007c-00dd-4423-9b7b-b87896c947fb
0 xwiki:XWiki.XWikiAllGroup edit
XWiki.XWikiRights
1
0
select
allow
allow
4
Allow/Deny
0
com.xpn.xwiki.objects.classes.BooleanClass
0
0
select
1
groups
1
Groups
0
5
0
1
com.xpn.xwiki.objects.classes.GroupsClass
0
0
select
1
levels
2
Levels
0
3
0
com.xpn.xwiki.objects.classes.LevelsClass
0
0
select
1
users
3
Users
0
5
0
1
com.xpn.xwiki.objects.classes.UsersClass
XWiki.ResetPassword
2
XWiki.XWikiRights
06daec64-228b-4da1-b7e6-b59d9624c866
1 XWiki.XWikiAllGroup view XWiki.XWikiGuest
{{velocity}} #** This page starts the password reset procedure. It works according to the next algorithm: 1. Display a form requesting the username 2. When receiving the username via form submission, generate a random verification string which is stored (as a hash) inside a ResetPasswordRequestClass object attached to the user's profile page. If no such object exists, it is created, but an existing object will be reused, meaning that at most one password reset request can be active at a moment. 3. Send an email to the address configured in the user's profile, containing a link to the second step of the password reset procedure.

URL parameters:

u = user account sent in the form *### ## ## ## The name of the class used for storing password reset verification data. #set ($verifClass = 'XWiki.ResetPasswordRequestClass') #set ($userName = "$!request.get('u')") #if ($userName == '')## First step, display the form requesting the username $msg.get('xe.admin.passwordReset.instructions')

{{html}} <form method="post" action="" class="xformInline"> <div> <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> <label for="u">$msg.get('xe.admin.passwordReset.username.label')</label> <input type="text" id="u" name="u"/> <span class="buttonwrapper"><input type="submit" value="$msg.get('xe.admin.passwordReset.submit')" class="button"/></span> </div> </form> {{/html}} #else## Second step, generate the verification string, store it, and send the email ## TODO: Once the usernames are not bound to the XWiki space, revisit this code #if ($userName.indexOf('.') != -1) #set ($userDoc = $xwiki.getDocumentAsAuthor(${userName})) #else #set ($userDoc = $xwiki.getDocumentAsAuthor("XWiki.${userName}")) #end ## Check if the user exists and has a valid email address configured in his profile #set ($userObj = '') #set ($userObj = $userDoc.getObject('XWiki.XWikiUsers')) #if (!$userObj)

{{warning}}$msg.get('xe.admin.passwordReset.error.noUser', ["//${escapetool.xml($userName)}//"]){{/warning}}

#elseif ($userDoc.getObject('XWiki.LDAPProfileClass'))

{{warning}}$msg.get('xe.admin.passwordReset.error.ldapUser', ["//${escapetool.xml($userName)}//"]){{/warning}}

#else #set ($userEmail = $userObj.getProperty('email').value) #if ("$!userEmail" == '')

{{error}}$msg.get('xe.admin.passwordReset.error.noEmail'){{/error}}

#else ## Find the object that will hold the verification string #set ($verifObj = '') #set ($verifObj = $userDoc.getObject($verifClass, true)) ## Generate a random string #set ($verifStr = $xwiki.generateRandomString(30)) ## If the class is correctly configured, the string should automatically be stored as a hash #set ($discard = $verifObj.set('verification', $verifStr)) #set ($discard = $userDoc.saveAsAuthor($msg.get('xe.admin.passwordReset.versionComment'), true)) ## Compose the verification URL #set ($passwordResetURL = $xwiki.getDocument('XWiki.ResetPasswordComplete').getExternalURL('view', "u=${userName}&amp;v=${verifStr}")) ## Send an email; the variables will be retrieved from the velocity context #set ($mailResult = $xwiki.mailsender.sendMessageFromTemplate($xwiki.getXWikiPreference('admin_email', 'no-reply@xwiki.org'), $userEmail, $util.null, $util.null, $xcontext.language, 'XWiki.ResetPasswordMailContent', $util.null)) #if ($mailResult == 0)

{{info}}$msg.get('xe.admin.passwordReset.emailSent', ["${escapetool.h}#${escapetool.xml($userEmail)}${escapetool.h}#"]){{/info}}

#else

{{error}}$msg.get('xe.admin.passwordReset.error.emailFailed'){{/error}}

#end #end #end [[$msg.get('xe.admin.passwordReset.error.retry')>>$doc.fullName]] | [[$msg.get('xe.admin.passwordReset.error.recoverUsername')>>ForgotUsername]] | [[$msg.get('xe.admin.passwordReset.login')>>path:$xwiki.getURL('XWiki.XWikiLogin', 'login')]] #end ## Clear private variables, so that they cannot be accessed from the rest of the page (comments, panels...) #set ($verifStr = '') #set ($passwordResetURL = '') {{/velocity}}