Back to index

moin  1.9.0~rc2
Functions
MoinMoin.action.recoverpass Namespace Reference

Functions

def _do_email
def _do_recover
def _create_form
def _create_token_form
def execute

Function Documentation

def MoinMoin.action.recoverpass._create_form (   request) [private]

Definition at line 60 of file recoverpass.py.

00060 
00061 def _create_form(request):
00062     _ = request.getText
00063     url = request.page.url(request)
00064     ret = html.FORM(action=url)
00065     ret.append(html.INPUT(type='hidden', name='action', value='recoverpass'))
00066     lang_attr = request.theme.ui_lang_attr()
00067     ret.append(html.Raw('<div class="userpref"%s>' % lang_attr))
00068     tbl = html.TABLE(border="0")
00069     ret.append(tbl)
00070     ret.append(html.Raw('</div>'))
00071 
00072     row = html.TR()
00073     tbl.append(row)
00074     row.append(html.TD().append(html.STRONG().append(html.Text(_("Username")))))
00075     row.append(html.TD().append(html.INPUT(type="text", size="36",
00076                                            name="name")))
00077 
00078     row = html.TR()
00079     tbl.append(row)
00080     row.append(html.TD().append(html.STRONG().append(html.Text(_("Email")))))
00081     row.append(html.TD().append(html.INPUT(type="text", size="36",
00082                                            name="email")))
00083 
00084     row = html.TR()
00085     tbl.append(row)
00086     row.append(html.TD())
00087     td = html.TD()
00088     row.append(td)
00089     td.append(html.INPUT(type="submit", name="account_sendmail",
00090                          value=_('Mail me my account data')))
00091 
00092     return unicode(ret)
00093 

Here is the caller graph for this function:

def MoinMoin.action.recoverpass._create_token_form (   request,
  name = None,
  token = None 
) [private]

Definition at line 94 of file recoverpass.py.

00094 
00095 def _create_token_form(request, name=None, token=None):
00096     _ = request.getText
00097     url = request.page.url(request)
00098     ret = html.FORM(action=url)
00099     ret.append(html.INPUT(type='hidden', name='action', value='recoverpass'))
00100     lang_attr = request.theme.ui_lang_attr()
00101     ret.append(html.Raw('<div class="userpref"%s>' % lang_attr))
00102     tbl = html.TABLE(border="0")
00103     ret.append(tbl)
00104     ret.append(html.Raw('</div>'))
00105 
00106     row = html.TR()
00107     tbl.append(row)
00108     row.append(html.TD().append(html.STRONG().append(html.Text(_("Username")))))
00109     value = name or ''
00110     row.append(html.TD().append(html.INPUT(type='text', size="36",
00111                                            name="name", value=value)))
00112 
00113     row = html.TR()
00114     tbl.append(row)
00115     row.append(html.TD().append(html.STRONG().append(html.Text(_("Recovery token")))))
00116     value = token or ''
00117     row.append(html.TD().append(html.INPUT(type='text', size="36",
00118                                            name="token", value=value)))
00119 
00120     row = html.TR()
00121     tbl.append(row)
00122     row.append(html.TD().append(html.STRONG().append(html.Text(_("New password")))))
00123     row.append(html.TD().append(html.INPUT(type="password", size="36",
00124                                            name="password")))
00125 
00126     row = html.TR()
00127     tbl.append(row)
00128     row.append(html.TD().append(html.STRONG().append(html.Text(_("New password (repeat)")))))
00129     row.append(html.TD().append(html.INPUT(type="password", size="36",
00130                                            name="password_repeat")))
00131 
00132     row = html.TR()
00133     tbl.append(row)
00134     row.append(html.TD())
00135     td = html.TD()
00136     row.append(td)
00137     td.append(html.INPUT(type="submit", name="recover", value=_('Reset my password')))
00138 
00139     return unicode(ret)
00140 

Here is the caller graph for this function:

def MoinMoin.action.recoverpass._do_email (   request,
  u 
) [private]

Definition at line 14 of file recoverpass.py.

00014 
00015 def _do_email(request, u):
00016     _ = request.getText
00017 
00018     if u and u.valid:
00019         is_ok, msg = u.mailAccountData()
00020         if not is_ok:
00021             return wikiutil.escape(msg)
00022 
00023     return _("If this account exists an email was sent.")
00024 

Here is the caller graph for this function:

def MoinMoin.action.recoverpass._do_recover (   request) [private]

Definition at line 25 of file recoverpass.py.

00025 
00026 def _do_recover(request):
00027     _ = request.getText
00028     form = request.form
00029     if not request.cfg.mail_enabled:
00030         return _("""This wiki is not enabled for mail processing.
00031 Contact the owner of the wiki, who can enable email.""")
00032 
00033     try:
00034         email = wikiutil.clean_input(form['email'].lower())
00035         if not email:
00036             # continue if email not given
00037             raise KeyError
00038 
00039         u = user.get_by_email_address(request, email)
00040 
00041         return _do_email(request, u)
00042     except KeyError:
00043         pass
00044 
00045     try:
00046         username = wikiutil.clean_input(form['name'])
00047         if not username:
00048             # continue if name not given
00049             raise KeyError
00050 
00051         u = user.User(request, user.getUserId(request, username))
00052 
00053         return _do_email(request, u)
00054     except KeyError:
00055         pass
00056 
00057     # neither succeeded, give error message
00058     return _("Please provide a valid email address or a username!")
00059 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.recoverpass.execute (   pagename,
  request 
)

Definition at line 141 of file recoverpass.py.

00141 
00142 def execute(pagename, request):
00143     found = False
00144     for auth in request.cfg.auth:
00145         if isinstance(auth, MoinAuth):
00146             found = True
00147             break
00148 
00149     if not found:
00150         # we will not have linked, so forbid access
00151         request.makeForbidden(403, 'No MoinAuth in auth list')
00152         return
00153 
00154     page = Page(request, pagename)
00155     _ = request.getText
00156     form = request.values # link in mail -> GET request
00157 
00158     if not request.cfg.mail_enabled:
00159         request.theme.add_msg(_("""This wiki is not enabled for mail processing.
00160 Contact the owner of the wiki, who can enable email."""), 'warning')
00161         page.send_page()
00162         return
00163 
00164     submitted = form.get('account_sendmail', '')
00165     token = form.get('token', '')
00166     newpass = form.get('password', '')
00167     name = form.get('name', '')
00168 
00169     if token and name and newpass:
00170         newpass2 = form.get('password_repeat', '')
00171         msg = _("Passwords don't match!")
00172         msg_type = 'error'
00173         if newpass == newpass2:
00174             pw_checker = request.cfg.password_checker
00175             pw_error = None
00176             if pw_checker:
00177                 pw_error = pw_checker(request, name, newpass)
00178                 if pw_error:
00179                     msg = _("Password not acceptable: %s") % pw_error
00180             if not pw_error:
00181                 u = user.User(request, user.getUserId(request, name))
00182                 if u and u.valid and u.apply_recovery_token(token, newpass):
00183                     msg = _("Your password has been changed, you can log in now.")
00184                     msg_type = 'info'
00185                 else:
00186                     msg = _('Your token is invalid!')
00187         if msg:
00188             request.theme.add_msg(msg, msg_type)
00189         if msg_type != 'error':
00190             page.send_page()
00191             return
00192 
00193     if token and name:
00194         request.theme.send_title(_("Password reset"), pagename=pagename)
00195 
00196         request.write(request.formatter.startContent("content"))
00197 
00198         request.write(_("""
00199 == Password reset ==
00200 Enter a new password below.""", wiki=True))
00201         request.write(_create_token_form(request, name=name, token=token))
00202 
00203         request.write(request.formatter.endContent())
00204 
00205         request.theme.send_footer(pagename)
00206         request.theme.send_closing_html()
00207     elif submitted: # user pressed create button
00208         if request.method != 'POST':
00209             return
00210         msg = _do_recover(request)
00211         request.theme.add_msg(msg, "dialog")
00212         page.send_page()
00213     else: # show create form
00214         request.theme.send_title(_("Lost password"), pagename=pagename)
00215 
00216         request.write(request.formatter.startContent("content"))
00217 
00218         request.write(_("""
00219 == Recovering a lost password ==
00220 If you have forgotten your password, provide your email address or
00221 username and click on '''Mail me my account data'''.
00222 You will receive an email containing a recovery token that can be
00223 used to change your password. The email will also contain further
00224 instructions.""", wiki=True))
00225 
00226         request.write(_create_form(request))
00227 
00228         request.write(request.formatter.rule())
00229 
00230         request.write(_("""
00231 === Password reset ===
00232 If you already have received the email with the recovery token, enter your
00233 username, the recovery token and a new password (twice) below.""", wiki=True))
00234 
00235         request.write(_create_token_form(request))
00236 
00237         request.write(request.formatter.endContent())
00238 
00239         request.theme.send_footer(pagename)
00240         request.theme.send_closing_html()

Here is the call graph for this function: