Exemple #1
0
def resetPassword2():
    '''
    Allows user to enter their new password as long as the key is valid.
    '''
    # check if password has been successfully reset
    succ = request.args.get('succ', False)
    if succ:
        return render_template('reset2.html', succ=True)

    email = request.args.get('e', False)
    key = request.args.get('k', False)
    err = request.args.get('r', False)
    if email and key and helpers.isValidEmail(email):
        if models.validReset(str(email), str(key)):
            return render_template('reset2.html', email=email, key=key, err=err)
    return "Invalid reset password URL.<br>"+\
        "Please verify that you copied and pasted the whole URL."
Exemple #2
0
def auth_reset():
    '''
    If e-mail is valid and in DB, sets a reset key in DB for user and sends a
    reset password link to the user's e-mail.
    '''
    err = False
    
    # validate email
    email = request.form.get('e',None)
    if email is not None and helpers.isValidEmail(email):
        if models.emailExists(email):
            key = models.setResetKey(email)
            helpers.sendResetEmail(email, key)
        else:
            err = 1
    else:
        err = 1
    
    if err:
        return redirect(url_for('resetPassword', email=email, r=err))
    return redirect(url_for('resetPassword', succ=1))