コード例 #1
0
def forgot():
    message_box = ""
    forgot_form = ForgotForm()

    #Only validate forms if the user pressed the submit button
    if 'submit_button' in request.form and request.form['submit_button'].strip(
    ) == 'Send Email':
        if forgot_form.validate_on_submit():
            user = User.query.filter_by(
                email=request.form['email'].strip()).first()
            if user == None:
                message_box = message_box_html(
                    'The provided email address is not associated with an account.',
                    error=True)
            else:
                msg = Message("Your password for ISU Event Planner",
                              sender=ADMINS[0],
                              recipients=[user.email])
                msg.body = "Your password for ISU Event Planner is: " + user.password
                msg.html = "<html>Your password for ISU Event Planner is: " + user.password + "</html>"
                send_async_email(msg)
                message_box = message_box_html('Password reminder sent.')
        else:  #Set error message to the first validation error.
            message_box = get_form_error(forgot_form)

    return render_template('forgot.html',
                           forgot_form=forgot_form,
                           message_box=message_box)
コード例 #2
0
def forgot():
    form = ForgotForm()
    if form.validate_on_submit():
        user = find_user(form.email.data)
        if user:
            salt = bcrypt.gensalt()
            password = bcrypt.hashpw(form.password.data.encode(), salt)
            users = []
            #opening users file putting the users in a list
            with open('data/users.csv', 'r') as f:
                for row in f:
                    users.append(row)
            #opening ursers file copying the entire users list with changed password
            with open('data/users.csv', 'w') as f:
                writer = csv.writer(f)
                for row in users:
                    row = row[:-1].split(",")
                    if len(row) >= 2 and form.email.data == row[1]:
                        row[2] = password.decode()
                        writer.writerow(row)
                    elif len(row) >= 2:
                        writer.writerow(row)
            flash(f'Password for {form.email.data} has been changed!',
                  'success')
            return redirect('/login')
        else:
            flash('This email does not exist. Try again.', 'danger')
    return render_template('forgot.html', title='Forgot', form=form)
コード例 #3
0
ファイル: pair.py プロジェクト: Vmodi2/TigerPair
def resend_email():
    error = ""
    form = ForgotForm()
    if form.validate_on_submit():
        email = form.email.data
        user = alumni.query.filter_by(info_email=email).first()
        if user is not None:

            token = s.dumps(email, salt='email-confirm')

            msg = Message('Confirm Email',
                          sender='*****@*****.**',
                          recipients=[email])
            link = url_for('confirm_email', token=token, _external=True)
            msg.body = 'Click here to verify email {}'.format(link)
            mail.send(msg)
            return redirect(url_for('gotoemail'))

        else:
            error = "Invalid credentials"

    html = render_template('pages/login/resend_email.html',
                           form=form,
                           errors=[error])  # MAKE THIS
    return make_response(html)
コード例 #4
0
ファイル: views.py プロジェクト: pychuang/ll-api
def forgot():
    form = ForgotForm(request.form)
    if form.validate_on_submit():
        try:
            core.user.reset_password(form.email.data)
        except Exception, e:
            flash(str(e), 'alert-warning')
            return redirect(url_for('user.forgot'))
        flash('A new password has been sent to %s.' % form.email.data,
              'alert-success')
        return redirect("/")
コード例 #5
0
def reset_request():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = ForgotForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        send_reset_email(user)
        flash(
            'An email has been sent to you with instructions to reset your password',
            'warning')
        return (redirect(url_for('login')))
    return render_template('admin/reset_request.html',
                           title='Password Reset',
                           form=form)
コード例 #6
0
ファイル: views.py プロジェクト: MadAd360/GoGramming
def forgot():
    form = ForgotForm()
    if form.validate_on_submit():
	user = form.user
        s = get_serializer(form.temppassword.data)
        payload = s.dumps(user.id)
        url = url_for('forgotchange', payload=payload, _external=True)
        msg = Message('Password Reset', sender = ADMINS[0], recipients = [user.email])
        msg.body = "Follow this link to reset password: " + url
        mail.send(msg)
        flash('Password Reset Email Sent')
        return redirect(url_for('login'))
    return render_template('forgot.html',
        title = 'Forgot Password',
        form = form)
コード例 #7
0
def forgot():
    forgotForm = ForgotForm()
    if request.method == "POST":
        if forgotForm.validate_on_submit():
            username = request.form.get('username')
            password = request.form.get('password')  #下一步用hash加密
            email = request.form.get('email')
            user = User.query.filter(User.username == username,
                                     User.email == email).first()
            if user:
                user.password = password
                db.session.commit()
                flash('用户密码已重置!')
                return render_template('forgot.html', form=forgotForm)

    return render_template('forgot.html', form=forgotForm)
コード例 #8
0
def index():
    email = None
    result, err = None, None
    f_form = ForgotForm()
    s_form = SignUp()
    l_login = LoginForm()
    if l_login.email_login.data and l_login.validate_on_submit():
        result, err = login(l_login)
        l_login.email_login.data = ''
    elif f_form.email_f.data and f_form.validate_on_submit():
        result, err = forgot(f_form)
        f_form.email_f.data = ''
    elif s_form.email_s.data and s_form.validate_on_submit():
        result, err = signup(s_form)
        s_form.email_s.data = ''
    return result if result else render_template(
        'fc.html', f_form=f_form, s_form=s_form, login_form=l_login, error=err)
コード例 #9
0
def forgot():

    a_email = session.get('aemail')
    if a_email:
        return redirect(url_for('admin'))

    stud_email = session.get('semail')
    if stud_email:
        return redirect(url_for('student'))

    form = ForgotForm()

    if form.validate_on_submit():
        email = form.email.data
        design = form.design.data

        info = db.execute("SELECT * FROM admininfo WHERE email = :email", {
            "email": email
        }).fetchone()
        info_one = db.execute("SELECT * FROM studentinfo WHERE email = :email",
                              {
                                  "email": email
                              }).fetchone()

        print(form.email.data)

        if design == "admin":
            if info:
                session['fpemailOne'] = info.email
                session['ades'] = "admin"
                return redirect(url_for('change_password'))
            else:
                flash(f'Sorry, your email does not exist, please check again.',
                      'danger')
                return redirect(url_for('forgot'))
        if design == "stud":
            if info_one:
                session['fpemailTwo'] = info_one.email
                session['sdes'] = "stud"
                return redirect(url_for('change_password'))
            else:
                flash(f'Sorry, your email does not exist, please check again.',
                      'danger')
                return redirect(url_for('forgot'))

    return render_template('forgotpass.html', form=form)
コード例 #10
0
ファイル: app.py プロジェクト: BenWileyUMN/DeltsDine
def forgot():
    form = ForgotForm(request.form)

    if form.validate_on_submit():
        member = session.query(Member).filter(
            Member.Email == form.email.data).first()
        if member is not None:
            sendForgotPasswordEmail(form.email.data)
            flash(
                "We just sent you an email to reset your password. Please follow the email link to finish this process."
            )

            return redirect(url_for('home'))
        else:
            flash(
                "Could not find the member. Please contact an administrator.")
            return redirect(url_for('home'))
    else:
        print(form.errors)
        return render_template('forms/forgot.html', form=form)
コード例 #11
0
ファイル: views.py プロジェクト: BradWells/fluidScheduler
def forgot():
	message_box = ""
	forgot_form = ForgotForm()

	#Only validate forms if the user pressed the submit button
	if 'submit_button' in request.form and request.form['submit_button'].strip() == 'Send Email':
		if forgot_form.validate_on_submit():
			user = User.query.filter_by(email = request.form['email'].strip()).first()
			if user == None:
				message_box = message_box_html('The provided email address is not associated with an account.', error=True)
			else:
				msg = Message("Your password for ISU Event Planner", sender=ADMINS[0], recipients=[user.email])
				msg.body = "Your password for ISU Event Planner is: " + user.password
				msg.html = "<html>Your password for ISU Event Planner is: " + user.password + "</html>"
				send_async_email(msg)
				message_box = message_box_html('Password reminder sent.')
		else:	#Set error message to the first validation error.
			message_box = get_form_error(forgot_form)

	return render_template('forgot.html', forgot_form=forgot_form, message_box=message_box)
コード例 #12
0
ファイル: app.py プロジェクト: spandana1234/projectmain
def forgotpassword():
    form = ForgotForm()
    if form.validate_on_submit():
        if request.method == 'POST':
            cursor = connection1.cursor()
            empid1 = form.empid.data
            global a
            a = empid1
            ques1 = form.select1.data
            ans1 = form.ans.data
            select = "SELECT ques,ans FROM profile where empid='" + empid1 + "'"
            cursor.execute(select)
            results = cursor.fetchone()
            if results is not None:
                ans = results[1]
                ques = results[0]
                if ans == ans1 and ques1 == ques:
                    return redirect(url_for("reset"))
                else:
                    flash('Please enter correct answer to question', 'danger')
            else:
                flash('Please enter correct Employee ID', 'danger')
    return render_template('forgotpassword.html', form=form)
コード例 #13
0
def forgot():
    form = ForgotForm()
    if form.validate_on_submit():
        flash('Mail has been sent to the provided email address', 'success')
        return redirect(url_for('reset'))
    return render_template('forgot.html', title='Forgot Password', form=form)