def change_email(): form = ChangeEmailForm() if form.validate_on_submit(): token = current_user.generate_confirmation_token() send_mail(form.email.data, 'Change email address', 'mail/change_email_mail', user = current_user, token = token, email = form.email.data) flash('Mail to confirm has been send in your new address') return redirect(url_for('index')) return render_template('auth/change_email.html', form = form)
def change_email(): ''' application for changing the email of a user ''' form = ChangeEmailForm() if form.validate_on_submit(): email = request.form['email'] functions.edit_email(email, session['id']) return redirect('/profile/settings/') return render_template('change_email.html', form=form, username=session['username'])
def change_email_request(): form = ChangeEmailForm() if form.validate_on_submit(): if current_user.verify_password(form.password.data): new_email = form.email.data token = current_user.generate_email_token(new_email) send_email(new_email,'确认你的邮箱地址','auth/email/change_email', user=current_user,token=token) flash('邮箱已经发送至你的邮箱请注意查收!') return redirect(url_for('main.index')) else: flash('邮箱或者密码错误') return render_template('auth/change_email.html',form=form)
def changeemail(): form = ChangeEmailForm() if form.validate_on_submit(): user = User.query.filter_by(email = current_user.email).first() if User.query.filter_by(email = form.newemail.data).first(): flash(u'该邮箱地址已被注册,请换用其他邮箱') else: if user.verify_password(form.password.data): token = user.generate_confirmationwithaddress_token(address = form.newemail.data) send_email(form.newemail.data, u'验证新的邮箱地址', '/auth/email/changeemail', user = user, token = token) flash(u'我们已向您的注册邮箱发送了一封重置邮箱确认邮件,请注意查收') else: flash(u'密码错误') return render_template('auth/changeemail.html', form = form)
def change_email(): flash('错误的邮箱地址可能导致账号丢失!请小心哦~', 'warning') form = ChangeEmailForm() if form.validate_on_submit(): current_user.email = form.email.data current_user.confirm = 0 db.session.add(current_user) db.session.commit() token = current_user.generate_confirm_user_token() send_email(current_user, current_user.email, 'change_email', token) flash( 'A email with token has been sent to your email, please check the junk box :P', 'success') return render_template('user/change_email.html', form=form)
def change_email_request(): form = ChangeEmailForm() if form.validate_on_submit(): if current_user.verify_password(form.password.data): new_email = form.email.data token = current_user.generate_email_change_token(new_email) send_email(new_email, 'Confirm your email address', 'auth/email/change_email', user=current_user, token=token) flash('An email with instructions to confirm your new email ' 'address has been sent to you.') return redirect(url_for('main.index')) else: flash('Invalid email or password.') return render_template("auth/change_email.html", form=form)
def profile_change_email(): form = ChangeEmailForm() if form.validate_on_submit(): if current_user.verify_password(form.password.data): new_email = form.email.data token = current_user.generate_email_change_token(new_email) confirm_url = url_for('main.confirm_email_change', token=token, _external=True) send_email_change_confirmation_email(new_email, confirm_url) flash( f'Confirmation of email change request was sent for {current_user.name}! Go to your email inbox and confirm.', 'success') return redirect(url_for('main.profile_change_email')) return render_template("profile_change_email.html", title='Register', form=form)
def changeEmail(): """ Change the users email """ form = ChangeEmailForm() user = current_user if form.validate_on_submit(): # check whether employee exists in the database and whether if user is not None: user.email = form.email.data db.session.commit() return redirect(url_for('home.myAccount')) # when email doesn't exist else: flash('Invalid email') return render_template('home/change.html', title="Change Email", form=form)
def admin(): admin = current_user admin_list = admin.search_all() add_admin_form = AddAdminForm() change_password_form = ChangePasswordForm() change_phone_form = ChangePhoneForm() change_email_form = ChangeEmailForm() change_info_form = ChangeInfoForm() if add_admin_form.validate_on_submit(): admin.add_new_admin(add_admin_form) flash('ADD ADMIN SUCCESS!') return redirect(url_for('views_blueprint.admin')) if change_password_form.validate_on_submit(): admin.change_password(change_password_form) flash('CHANGE PASSWORD SUCCESS!') return redirect(url_for('views_blueprint.admin')) if change_phone_form.validate_on_submit(): admin.change_phone(change_phone_form) flash('CHANGE PHONE SUCCESS!') return redirect(url_for('views_blueprint.admin')) if change_email_form.validate_on_submit(): admin.change_email(change_email_form) flash('CHANGE EMIAL SUCCESS!') return redirect(url_for('views_blueprint.admin')) if change_info_form.validate_on_submit(): admin.change_info(change_info_form) flash('CHANGE INFO SUCCESS!') return redirect(url_for('views_blueprint.admin')) return new_render_template('admin.html', admin_list=admin_list, change_password_form=change_password_form, change_phone_form=change_phone_form, change_email_form=change_email_form, change_info_form=change_info_form, add_admin_form=add_admin_form, page_title='ADMIN')