Пример #1
0
def reset_password(token):

    try:
        username = ts.loads(token, salt="username-confirm-key", max_age=86400)
    except:
        abort(404)

    return render_template('changePassword.html', username=username)
Пример #2
0
def confirm_email(token):
    email = ts.loads(token, salt='email-confirm-key', max_age=86400)
    user = User.query.filter_by(email=email).first_or_404()
    logger.debug("User finded: {}".format(user))
    user.active = True
    try:
        database.session.commit()
    except Exception as error:
        return 'error: {}'.format(error)
    flash("Konto aktywowane")
    return redirect(url_for('login'))
Пример #3
0
def password_reset(token):
    form = PasswordResetForm()
    if form.validate_on_submit():
        email = ts.loads(token, salt='password-reset-key', max_age=86400)
        user = User.query.filter_by(email=email).first_or_404()
        user.set_password(form.new_password.data)
        try:
            database.session.commit()
        except Exception as error:
            return 'error: {}'.format(error)
        flash('Hasło zostało zmienione.')
        return redirect(url_for('index'))
    return render_template('password_reset.html', form=form)
Пример #4
0
def confirm_email(token):

    try:
        email = ts.loads(token, salt="email-confirm-key", max_age=86400)
    except:
        abort(404)

    user = confirm_user(email)

    if user.email_confirmed:
        flash('User created successfully!')
        return home()
    else:
        flash('User invalid confirmation token!')
Пример #5
0
def user_email_verification(token):
    try:
        email = ts.loads(token, salt="email-confirm-key", max_age=86400)
        user = User.query.filter_by(email=email).first()
        if user:
            user.email_verified = True
            db.session.commit()
            return  # ask arvind what all data does he require after verification
        else:
            return Response(mimetype="application/json",
                            response=json.dumps({'error': 'User not found'}),
                            status=404)
    except Exception as e:
        error_msg = get_error_msg(e)
        logger.error(error_msg)
        return Response(mimetype="application/json",
                        response=json.dumps({'error': error_msg}),
                        status=400)