def account_locked(): now = datetime.utcnow() form = ResendConfirmationForm(request.form) if request.method == 'GET': return render_template( 'users/account/locked.html', now=now, form=form, ) if request.method == 'POST': password_reset_serializer = URLSafeTimedSerializer( app.config['SECRET_KEY']) theuser = form.username.data theemail = form.email.data flash("If the information provided is correct, an email will be sent.", category="success") password_reset_url = url_for('users.unlock_with_token', token=password_reset_serializer.dumps( theemail, salt='password-reset-salt'), _external=True) authfail = render_template('users/email/accountlocked.html', user=theuser, now=now, password_reset_url=password_reset_url) send_email('answer.cash - Account Locked', [theemail], '', authfail) return redirect(url_for('users.account_locked'))
def welcome(): user = db.session\ .query(User)\ .filter_by(id=current_user.id)\ .first() # subscribe users to basic subs seeifanysubs = db.session \ .query(Subscribed) \ .filter(Subscribed.user_id == current_user.id, Subscribed.subcommon_id == 1) \ .first() if seeifanysubs is None: one = Subscribed( user_id=user.id, subcommon_id=1, ) db.session.add(one) db.session.commit() # get user subforums usersubforums = db.session.query(Subscribed) \ .join(SubForums, (Subscribed.subcommon_id == SubForums.id)) \ .filter(current_user.id == Subscribed.user_id) \ .filter(SubForums.id != 1) \ .all() if current_user.confirmed == 0: # email stuff password_reset_serializer = URLSafeTimedSerializer( app.config['SECRET_KEY']) confirm_account_url = url_for('users.confirm_account_with_token', token=password_reset_serializer.dumps( user.email, salt='password-reset-salt'), _external=True) # account email accountreg = render_template('users/email/welcome.html', user=user.user_name, now=datetime.utcnow(), password_reset_url=confirm_account_url) try: send_email('Welcome to Answer.cash!', [user.email], '', accountreg) # end email stuff except: pass return render_template('main/welcome.html', now=datetime.utcnow(), usersubforums=usersubforums)
def confirmationforwallets(): now = datetime.utcnow() form = ResendConfirmationForm(request.form) if request.method == 'GET': pass if request.method == 'POST': if form.validate_on_submit(): user = db.session\ .query(User)\ .filter_by(user_name=form.username.data)\ .first() if user is not None: if user.email == form.email.data: if user.confirmed == 0: # login user password_reset_serializer = URLSafeTimedSerializer( app.config['SECRET_KEY']) confirm_account_url = url_for( 'users.confirm_account_with_token', token=password_reset_serializer.dumps( user.email, salt='password-reset-salt'), _external=True) accountreg = render_template( 'users/email/resendconfirm.html', user=user.user_name, now=now, password_reset_url=confirm_account_url) send_email('Welcome to answer.cash! ', [user.email], '', accountreg) flash( "Please check your email for link to confirm account", category="success") return redirect(url_for('index')) else: flash("Your Account is already confirmed", category="danger") return redirect(url_for('index')) else: flash("Incorrect Information", category="danger") return redirect(url_for('users.confirmationforwallets')) else: flash("User Doesnt exist", category="danger") return redirect(url_for('users.resendconfirmation')) else: flash("Form Error", category="danger") return redirect(url_for('users.resendconfirmation')) return render_template('/users/resendconfirmation.html', form=form)
def send_pin_reset_email(user_email): now = datetime.utcnow() password_reset_serializer = URLSafeTimedSerializer(app.config['SECRET_KEY']) password_reset_url = url_for( 'users.reset_walletpin_token', token=password_reset_serializer.dumps(user_email, salt='password-reset-salt'), _external=True) user = db.session.query(User).filter_by(email=user_email).first() lostpwdtemp = render_template('users/email/lostpinemailtemplate.html', user=user, now=now, password_reset_url=password_reset_url) send_email('Pin Reset Requested', [user_email], '', lostpwdtemp)