Пример #1
0
def assign_new_passwd_view(login, token):
    if g.permission > 0:
        return redirect('/cabinet')
    if not User.check_login_token(login, token):
        flash('You shall not pass!', 'text-danger')
        return redirect('/')
    form = NewPasswdForm()
    if form.validate_on_submit():
        User.update_passwd(User.get_user_id(login), form.passwd.data)
        flash(RESET_PASSWD_CONFIRMED, 'text-success')
        return redirect('/')
    return render_template('new_passwd.html', form=form)
Пример #2
0
def settings_profile_view():
    if g.permission < 1:
        flash(NOT_AUTH_MSG, 'text-warning')
        return redirect('/')
    form = EditProfileForm()
    if form.validate_on_submit():
        User.update_profile(session['id'], form.login.data,
                            form.first_name.data, form.last_name.data,
                            form.birth_date.data, form.gender.data,
                            form.preferences.data, form.biography.data,
                            form.city.data, form.show_location.data)
        if form.passwd.data != '':
            User.update_passwd(session['id'], form.passwd.data)
        if form.email.data != User.get_email(session['id']):
            flash(UPDATE_EMAIL, 'text-success')
            User.send_update_email_rwquest(form.email.data, session['login'],
                                           session['id'])
        if form.interests.data != ', '.join(
                User.get_interests_list(session['id'])):
            User.update_interesrs(session['id'], form.interests.data)
        flash(UPDATED, 'text-success')
    User.fill_edit_profile_form_from_db(form, session['id'])
    return render_template('settings_profile.html', form=form)