auth/views.py
def forgot_password(request):
    """Request a a password reset email.

    A user can enter an email address into a form.  Submitting causes
    an email containing a URL that can be clicked to restore access.
    """
    if request.user:
        return http.HttpResponseForbidden('Logged-in users prohibited.')
    # TODO(trow): Rate-limit password reset emails?
    tmpl = loader.get_template('auth/forgot_password.html')
    ctx_vars = {
        'title': 'Recover Forgotten Password',
        }
    if request.method == 'GET':
        ctx_vars['form'] = auth_forms.ForgotPasswordForm()
    else:
        form = auth_forms.ForgotPasswordForm(request.POST)
        if not form.is_valid():
            ctx_vars['form'] = form
        else:
            ctx_vars['email'] = form.user.email
            # Assemble the URL that can be used to access the password
            # reset form.
            token = auth.get_password_reset_token(form.user)
            url = 'http://%s/auth/reset_password?token=%s' % (
                os.environ['HTTP_HOST'], token)
            logging.warn('Sent password recovery URL: %s', url)
            # Construct and send the email message
            msg_tmpl = loader.get_template('auth/forgot_password_email.txt')
            msg_ctx = Context({'user': form.user, 'url': url})
            msg_body = msg_tmpl.render(msg_ctx)
            # Actually send the email message.
            email.send_to_user(
                form.user,
                subject='Recovering your forgotten CHIRP password',
                body=msg_body)
    ctx = RequestContext(request, ctx_vars)
    return http.HttpResponse(tmpl.render(ctx))
Request a a password reset email.

    A user can enter an email address into a form.  Submitting causes
    an email containing a URL that can be clicked to restore access.
    
Request a a password reset email.
A user can enter an email address into a form.  Submitting causes
an email containing a URL that can be clicked to restore access.
Request a a password reset email . A user can enter an email address into a form . Submitting causes an email containing a URL that can be clicked to restore access .
def forgot_password(request):
    if request.user:
        return http.HttpResponseForbidden('Logged-in users prohibited.')
    tmpl = loader.get_template('auth/forgot_password.html')
    ctx_vars = {
        'title': 'Recover Forgotten Password',
        }
    if request.method == 'GET':
        ctx_vars['form'] = auth_forms.ForgotPasswordForm()
    else:
        form = auth_forms.ForgotPasswordForm(request.POST)
        if not form.is_valid():
            ctx_vars['form'] = form
        else:
            ctx_vars['email'] = form.user.email
            token = auth.get_password_reset_token(form.user)
            url = 'http://%s/auth/reset_password?token=%s' % (
                os.environ['HTTP_HOST'], token)
            logging.warn('Sent password recovery URL: %s', url)
            msg_tmpl = loader.get_template('auth/forgot_password_email.txt')
            msg_ctx = Context({'user': form.user, 'url': url})
            msg_body = msg_tmpl.render(msg_ctx)
            email.send_to_user(
                form.user,
                subject='Recovering your forgotten CHIRP password',
                body=msg_body)
    ctx = RequestContext(request, ctx_vars)
    return http.HttpResponse(tmpl.render(ctx))
def forgot_password ( request ) : if request . user : return http . HttpResponseForbidden ( 'Logged-in users prohibited.' ) tmpl = loader . get_template ( 'auth/forgot_password.html' ) ctx_vars = { 'title' : 'Recover Forgotten Password' , } if request . method == 'GET' : ctx_vars [ 'form' ] = auth_forms . ForgotPasswordForm ( ) else : form = auth_forms . ForgotPasswordForm ( request . POST ) if not form . is_valid ( ) : ctx_vars [ 'form' ] = form else : ctx_vars [ 'email' ] = form . user . email token = auth . get_password_reset_token ( form . user ) url = 'http://%s/auth/reset_password?token=%s' % ( os . environ [ 'HTTP_HOST' ] , token ) logging . warn ( 'Sent password recovery URL: %s' , url ) msg_tmpl = loader . get_template ( 'auth/forgot_password_email.txt' ) msg_ctx = Context ( { 'user' : form . user , 'url' : url } ) msg_body = msg_tmpl . render ( msg_ctx ) email . send_to_user ( form . user , subject = 'Recovering your forgotten CHIRP password' , body = msg_body ) ctx = RequestContext ( request , ctx_vars ) return http . HttpResponse ( tmpl . render ( ctx ) )
Request a a password reset email.
Request a a password reset email .
"""Request a a password reset email.

    A user can enter an email address into a form.  Submitting causes
    an email containing a URL that can be clicked to restore access.
    """ # TODO(trow): Rate-limit password reset emails? # Assemble the URL that can be used to access the password # reset form. # Construct and send the email message # Actually send the email message.
request