title: web2py custom reset password
body: <p>How to create custom reset password form in Web2Py?</p>
  
  <p><strong>request_reset_password</strong> </p>
  
  <pre><code>def request_reset_password(): 
        site_url = 'www.site.com/myproject/'
        auth.settings.request_reset_password_next = URL('account', args='request sent')
        auth.messages.reset_password ='please click this link http://' + site_url+ 'account/reset_password'+ '/?key='+'%(key)s to reset your password' 
        form= auth.request_reset_password()
        form.custom.submit['_data-theme'] = 'e'
        form.custom.submit['_data-ajax'] = 'false'
        return dict(form=form)
  </code></pre>
  
  <p><strong>reset_password</strong> </p>
  
  <pre><code>def reset_password():
        user = db.auth_user
        if request.vars.key:
            key = request.vars.key
            users = db(user.reset_password_key == key).select()
            if not users:
                session.flash='Invalid password reset'
                #redirect(next) 
  
            form=FORM(INPUT(_name='password', _type="password", requires=[IS_NOT_EMPTY()]),INPUT(_type='submit', _value='Click to perform password reset'))
            if form.accepts(request,session):
                key= request.vars.key if request.vars.key else _error()
                password= request.vars.password if request.vars.password else _error()
                users = db(user.reset_password_key == key).select()
               if not users:
                   session.flash='Invalid password reset'
                   #redirect(next) 
               users[0].update_record(password=CRYPT(key=auth.settings.hmac_key)(password)[0],reset_password_key='')
                  #session.flash='Password was reset'
                  #redirect(next)
  
        return dict(form=form)
  </code></pre>
  
  <p>To add a view for the both functions try this code .</p>
  
  <pre><code>{{extend 'layout.html'}} 
  {{=form}}
  </code></pre>