Beispiel #1
0
def change_email(token):
    if validate_token(user=current_user, token=token, operation=Operations.CHANGE_EMAIL):
        flash('Email updated.', 'success')
        return redirect(url_for('.index', username=current_user.username))
    else:
        flash('Invalid or expired token.', 'warning')
        return redirect(url_for('.change_email_request'))
Beispiel #2
0
def change_email(token):
    if validate_token(user=current_user, token=token, operation=Operations.CHANGE_EMAIL):
        flash(_('Email обновлен.'), 'success')
        return redirect(url_for('.index', username=current_user.username))
    else:
        flash(_('Неверный или просроченный токен.'), 'warning')
        return redirect(url_for('.change_email_request'))
Beispiel #3
0
def change_email(token):
    if validate_token(user=current_user,
                      token=token,
                      operation=Operations.CHANGE_EMAIL):
        flash('Адрес почты обновлен', 'success')
        return redirect(url_for('.index', username=current_user.username))
    else:
        flash('Неправильный или истекший токен', 'warning')
        return redirect(url_for('.change_email_request'))
Beispiel #4
0
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('main.index'))

    if validate_token(user=current_user, token=token, operation=Operations.CONFIRM):
        flash(_('Account confirmed.'), 'success')
        return redirect(url_for('main.index'))
    else:
        flash(_('Invalid or expired token.'), 'danger')
        return redirect(url_for('.resend_confirm_email'))
Beispiel #5
0
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('main.index'))

    if validate_token(user=current_user,
                      token=token,
                      operation=Operations.CONFIRM):
        flash(_('Аккаунт подтвержден.'), 'success')
        return redirect(url_for('main.index'))
    else:
        flash(_('Неверный или просроченный токен.'), 'danger')
        return redirect(url_for('.resend_confirm_email'))
Beispiel #6
0
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('main.index'))

    if validate_token(user=current_user,
                      token=token,
                      operation=Operations.CONFIRM):
        flash('Аккаунт подтвержден', 'success')
        return redirect(url_for('main.index'))
    else:
        flash('Неправильное значение/истек срок токена', 'danger')
        return redirect(url_for('.resend_confirm_email'))
Beispiel #7
0
def reset_password(token):
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))

    form = ResetPasswordForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data.lower()).first()
        if user is None:
            return redirect(url_for('main.index'))
        if validate_token(user=user, token=token, operation=Operations.RESET_PASSWORD,
                          new_password=form.password.data):
            flash(_('Password updated.'), 'success')
            return redirect(url_for('.login'))
        else:
            flash(_('Invalid or expired link.'), 'danger')
            return redirect(url_for('.forget_password'))
    return render_template('auth/reset_password.html', form=form)