コード例 #1
0
ファイル: views.py プロジェクト: hack4impact/idle-free-philly
def change_email_request():
    """Respond to existing user's request to change their 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)
            change_email_link = url_for_external('account.change_email',
                                                 token=token)
            get_queue().enqueue(
                send_email,
                recipient=new_email,
                subject='Confirm Your New Email',
                template='account/email/change_email',
                # current_user is a LocalProxy, we want the underlying user
                # object
                user=current_user._get_current_object(),
                change_email_link=change_email_link
            )
            flash('A confirmation link has been sent to {}.'.format(new_email),
                  'warning')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid email or password.', 'form-error')
    return render_template('account/manage.html', form=form)
コード例 #2
0
ファイル: views.py プロジェクト: GJhunter/fight-flask
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)
コード例 #3
0
ファイル: views.py プロジェクト: Leyawiin/FlaskDemo
def change_email_request():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.email != form.email.data or not current_user.verify_password(form.password.data):
            flash('Invalide email or password')
        else:
            token = current_user.generate_email_change_token(form.newemail.data)
            send_email(form.newemail.data, 'Confirm Your Email',
                       'auth/email/change_email',token=token,user=current_user)
            flash('An confirm email has been send to you new Email address')
            return redirect(url_for('main.index'))
    return render_template('auth/change_email.html',form=form)
コード例 #4
0
def change_email_request():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            token = current_user.generate_email_change_token(form.email.data)
            send_email(form.email.data, 'Change Your Email', 'auth/email/change_email',
                       user=current_user, token=token)
            flash('A change-email email has been sent to you by new email.')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid password.')
    return render_template("auth/change_email.html", form=form)
コード例 #5
0
ファイル: views.py プロジェクト: whytin/whytin-blog
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, '确认你的邮箱', '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)
コード例 #6
0
def change_email_request():
	form = ChangeEmailForm()
	if form.validate_on_submit():
		if current_user.verify_password(form.password.data):
			new_mail = form.email.data
			token = current_user.generate_email_change_token(new_mail)
			send_email(new_mail, '确认您的邮箱地址', '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)
コード例 #7
0
ファイル: views.py プロジェクト: RachelQ1103/QiuBai
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)
            print(url_for('auth.change_email', token=token, _external=True))
            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)
コード例 #8
0
ファイル: views.py プロジェクト: yaoice/flask
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, u'确认您的邮件地址', 'auth/email/change_email', user=current_user, token=token)
                                          flash(u'邮件已发送,请到新邮件地址查收!')
                                          return redirect(url_for('main.index'))
                            else:
                                          flash(u'密码错误')
              return render_template("auth/change_email.html", form=form)
コード例 #9
0
ファイル: views.py プロジェクト: onelove1991/fach
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"))
        flash("Invalid email or password.")
    return render_template("auth/change_email.html", form=form)
コード例 #10
0
ファイル: views.py プロジェクト: niravhjoshi/HerokuDeploy
def change_email():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            newemail = form.email.data
            token = current_user.generate_email_change_token(newemail)
            send_email(form.email.data,'Confirm Your Email Update','mail/auth/change_em',user = current_user.fname,token = token)
            flash('We have send email to your new email address please check on activation {0}'.format(newemail))
            return redirect(url_for('main.index'))

        else:
            flash('Invalid email id or password ')
    return render_template('auth/change_email.html',form=form)
コード例 #11
0
ファイル: views.py プロジェクト: frjurado/flask-rep
def change_email_request():
    """
    Change email associated with your account.
    The new email will be pending until you confirm it.
    """
    form = ChangeEmailForm(current_user)
    if form.validate_on_submit():
        new_email = form.email.data
        token = current_user.generate_email_change_token(new_email)
        email.change_email(current_user, new_email, token)
        flash(u"A confirmation link has been sent to your new email.")
        return to_dashboard()
    return auth_form(form)
コード例 #12
0
ファイル: views.py プロジェクト: yyt030/badou.com
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(u"确认邮件已发出")
            return redirect(url_for("main.index"))
        else:
            flash(u"无效用户名或密码.")
    return render_template("auth/change_email.html", form=form)
コード例 #13
0
ファイル: views.py プロジェクト: chen940303/Diaosier_home
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, '邮箱地址更改认证',
                       'auth/email/change_email',
                       user=current_user, token=token)
            flash(u'修改邮箱的认证邮件已发往您的新邮箱')
            return redirect(url_for('main.index'))
        else:
            flash(u'密码不正确')
    return render_template("auth/change_email.html", form=form)
コード例 #14
0
ファイル: views.py プロジェクト: eastossifrage/ousi373
def change_email_request():
    change_email_form = ChangeEmailForm(prefix='change_email')
    if change_email_form.validate_on_submit():
        if current_user.verify_password(change_email_form.password.data):
            new_email = change_email_form.email.data.strip()
            token = current_user.generate_email_change_token(new_email)
            send_email(new_email, u'更新邮箱',
                       'auth/email/change_email_',
                       user=current_user, token=token)
            flash({'success': u'一封确认邮件已发至您的邮箱'})
        else:
            flash({'error': u'密码错误!'})

    return render_template("auth/config/change_email.html", changeEmailForm=change_email_form)
コード例 #15
0
ファイル: views.py プロジェクト: mvbn6789/flask-blog
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(u'邮件已发送至新邮箱')
            return redirect(url_for('main.index'))
        else:
            flash(u'邮箱或密码无效')
    return render_template("auth/change_email.html", form=form)
コード例 #16
0
ファイル: views.py プロジェクト: hellckt/SONGXUE
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, u'确认你的邮箱地址',
                       'auth/email/change_email',
                       user=current_user, token=token)
            flash(u'验证邮件将会发送到你的邮箱。')
            return redirect(url_for('main.index'))
        else:
            flash(u'错误的邮箱或密码。')
    return render_template("auth/change_email.html", form=form)
コード例 #17
0
ファイル: views.py プロジェクト: sikasjc/sika
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, '确认新邮箱',
                       '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)
コード例 #18
0
ファイル: views.py プロジェクト: richgieg/flask-now
def change_email_request():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if verify_password(current_user, 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_it(AuthMessages.EMAIL_CHANGE_REQUEST)
            return form.redirect(url_for('main.user',
                                         username=current_user.username))
        else:
            flash_it(AuthMessages.INVALID_PASSWORD)
    return render_template("auth/change_email.html", form=form)
コード例 #19
0
ファイル: views.py プロジェクト: manhtai/vietnom
def change_email_request():
    form = ChangeEmailForm()
    if form.validate_on_submit() and current_user.enabled:
        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, _('Xác nhận địa chỉ email mới'),
                       'auth/email/change_email',
                       user=current_user, token=token)
            flash(_('Một email với hướng dẫn xác nhận đã được gửi đi'))
            return redirect(url_for('.change_email_request'))
        else:
            flash(_('Mật khẩu chưa đúng'))
    selection = Tab(4, _('Thay đổi email'))
    return render_template("settings/settings.html",
                           form=form, selection=selection)
コード例 #20
0
def change_email_request():
    """ user request to change their passwords """
    form = ChangeEmail()
    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("We have send an email with instruction how to reset your password")
            return redirected(url_for("main.index"))
        else:
            flash("Password is Invalid")
    return render_template("auth/change_email.html", form=form)
コード例 #21
0
def change_email_request():
    ''' user request to change their passwords '''
    form = ChangeEmail()
    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('We have send an email with instruction how to reset your password')
            return redirect(url_for('main.index'))
        else:
            flash('Password is Invalid')
    return render_template('auth/change_email.html', form=form)
コード例 #22
0
ファイル: views.py プロジェクト: guoronghua/CommonCrawler
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)
コード例 #23
0
ファイル: server.py プロジェクト: santosomar/cve-portal
def change_email_request():
    form = form_class.ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            new_email = escape(form.email.data)
            token = current_user.generate_email_change_token(new_email)
            send_email(new_email,
                       'CVE-PORTAL -- Confirm your email address',
                       '/emails/change_email',
                       user=current_user,
                       token=token)
            syslog.syslog(syslog.LOG_WARNING, "User as requested an email change: Old:" + current_user.email + " New: " + form.email.data)
            flash('An email with instructions to confirm your new email address has been sent to you.', 'info')
            return redirect(url_for('index'))
        else:
            flash('Invalid email or password.', 'danger')
    return render_template("auth/change_email.html", form=form)
コード例 #24
0
ファイル: views.py プロジェクト: peter14f/flasky
def change_email_request():
    form = ChangeEmailRequestForm()
    if form.validate_on_submit():
        if not current_user.verify_password(form.password.data):
            flash("Wrong password!")
            return redirect(url_for('auth.change_email_request'))
        if not User.query.filter_by(email=form.newemail.data).first() is None:
            flash("You may not use this email because it's already registered with Flasky")
            return redirect(url_for('auth.change_email_request'))

        token = current_user.generate_email_change_token(form.newemail.data)
        send_mail(form.newemail.data, 'Change Email Registered with Flask',
                  'auth/email/change_email',
                  email=form.newemail.data, token=token)
        flash('A link to reset your email registered with Flasky has been mailed to ' + "'" + form.newemail.data + "'")
        return redirect(url_for('main.index'))
    return render_template('auth/change_email.html', form=form)
コード例 #25
0
ファイル: controller.py プロジェクト: aip/phics
def request_to_change_email():
    form = EmailChangeForm()
    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)
            email.send(
                new_email,
                i18n.label(request_to_change_email, 'email_subject'),
                'change_email',
                user=current_user,
                token=token
            )
            i18n.flash(request_to_change_email, 'successful')
            return redirect(url_for('main.index'))
        else:
            i18n.flash(request_to_change_email, 'fail')
    return render_template("change_email.html", form=form)
コード例 #26
0
ファイル: user.py プロジェクト: xavierdavidgarcia/cve-portal
def change_email_request():
    form = form_class.ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            new_email = escape(form.email.data)
            token = current_user.generate_email_change_token(new_email)
            send_email(new_email,
                       'CVE-PORTAL -- Confirm your email address',
                       '/emails/change_email',
                       user=current_user,
                       token=token)
            syslog.syslog(syslog.LOG_WARNING,
                          "User as requested an email change: Old:" + current_user.email + " New: " + form.email.data)
            flash('An email with instructions to confirm your new email address has been sent to you.', 'info')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid email or password.', 'danger')
    return render_template("auth/change_email.html", form=form)
コード例 #27
0
def change_email_request():
    """Respond to existing user's request to change their 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)
            send_email(new_email,
                       'Confirm Your New Email',
                       'account/email/change_email',
                       user=current_user,
                       token=token)
            flash('A confirmation link has been sent to {}.'.format(new_email),
                  'warning')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid email or password.', 'form-error')
    return render_template('account/manage.html', form=form)
コード例 #28
0
ファイル: views.py プロジェクト: hellokuku/flask_demo
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',
                       'auth/mail/change_email',
                       user=current_user,
                       token=token)
            flash(
                'An email with instructions to confirm your new email addr to you by email '
            )
        else:
            flash('Invalid email or password.')
    return render_template('auth/change_email.html',
                           user=current_user,
                           form=form)
コード例 #29
0
def change_email():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            newemail = form.email.data
            token = current_user.generate_email_change_token(newemail)
            send_email(form.email.data,
                       'Confirm Your Email Update',
                       'mail/auth/change_em',
                       user=current_user.fname,
                       token=token)
            flash(
                'We have send email to your new email address please check on activation {0}'
                .format(newemail))
            return redirect(url_for('main.index'))

        else:
            flash('Invalid email id or password ')
    return render_template('auth/change_email.html', form=form)
コード例 #30
0
ファイル: views.py プロジェクト: ZyqGitHub1/raspberry_cloud
def change_email_request():
	data = request.form
	if current_user.verify_password(data.get('oldpassword')):
		new_email = data.get('email')
		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)
		result = {
		'successful':True,
		'msg':'一封确认邮件已经发送到您的新邮箱'
		}
		return jsonify(result)
	else:
		result = {
		'successful':False,
		'msg':'错误的邮箱或密码'
		}
		return jsonify(result)
コード例 #31
0
ファイル: view.py プロジェクト: margierain/Andela21-project
def change_email_request():
    ''' user request to change their passwords '''
    form = ChangeEmail()
    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(
                'We have send an email with instruction how to reset your password'
            )
            return redirected(url_for('main.index'))
        else:
            flash('Password is Invalid')
    return render_template('auth/change_email.html', form=form)
コード例 #32
0
def change_email_request():
    form = ChangeEmailForm(current_user)

    if form.validate_on_submit():
        if form.email.data.lower().strip() != current_user.email:
            new_email = form.email.data.lower().strip()
            token = current_user.generate_email_change_token(new_email)
            send_email(
                new_email, "Confirm Your Email Address",
                render_template("email/confirm-change-email.html",
                                user=current_user,
                                token=token))

            flash(
                "To finish updating your email address, please click the link "
                "that we just sent to your new address")
        return redirect(url_for("auth.portal"))

    form.email.data = current_user.email
    return render_template("auth.html",
                           form_title="Change Your Email",
                           form=form)
コード例 #33
0
def change_email_request():
    form = ChangeEmailForm()
    if form.validate_on_submit() and\
    request.form.get('button', None) == "Change Email":
        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(
                'change_email',
                token=token,
                _external=True)
            create_email(current_user, new_email,
                        'Confirm Your Email Address Change',
                        'email/change_email',
                        confirm_url)
            flash('Instructions on confirming your new email '
                  'address have been sent to you.')
            return redirect(url_for('profile'))
        else:
            flash('Invalid password.')
    elif request.form.get('button', None) == "Cancel":
        return redirect(url_for('profile'))
    return render_template('change_email.html', form=form)
コード例 #34
0
ファイル: views.py プロジェクト: HeathKang/zhihufake
def setting():
    email_form = ChangeEmailForm()
    password_form = ChangePasswordForm()
    if email_form.validate_on_submit():
        if current_user.verify_password(email_form.password.data):
            new_email = email_form.email.data
            token = current_user.generate_email_change_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('邮箱地址或密码错误')
    if password_form.validate_on_submit():
        if current_user.verify_password(password_form.old_password.data):
            current_user.password = password_form.password.data
            db.session.add(current_user)
            flash('您的密码已更改')
            return redirect(url_for('main.index'))
        else:
            flash('无效的密码')
    return render_template('auth/setting.html',email_form=email_form,password_form=password_form)
コード例 #35
0
def change_email_request():
    """Respond to existing user's request to change their 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)
            change_email_link = url_for(
                'account.change_email', token=token, _external=True)
            get_queue().enqueue(
                send_email,
                recipient=new_email,
                subject='Confirm Your New Email',
                template='account/email/change_email',
                # current_user is a LocalProxy, we want the underlying user
                # object
                user=current_user._get_current_object(),
                change_email_link=change_email_link)
            flash('A confirmation link has been sent to {}.'.format(new_email),
                  'warning')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid email or password.', 'form-error')
    return render_template('account/manage.html', form=form)
コード例 #36
0
ファイル: views.py プロジェクト: stoodsteal/flasky
#-*- coding: utf-8 -*-