def register(): if not app.config['APP_REGISTER']: return render_template('user_register_disabled.html.j2') form = RegisterForm() if request.method == 'POST' and form.validate(): if User.objects(email=form.email.data).first() is None: if User.objects().first() is None: profile = "ADMIN" #make 1st user ADMIN else: profile = "USER" new_user = User( email=form.email.data, password=form.password.data, profile=profile, ).save() send_confirmation_email(new_user) login_user(new_user) return redirect(url_for('user_unconfirmed')) else: flash('Email already registered "{}"'.format(form.email.data)) flash_form_errors(form) return redirect(url_for('index'))
def email_edit(): form = EmailForm() if request.method == 'POST' and form.validate(): if User.objects(email=form.email.data).first() is None: user = User.objects(email=current_user.email).first() user.email = form.email.data user.confirmed = False user.save() send_confirmation_email(user) flash( "Your email has been updated, please confirm the new email address" ) return redirect(url_for('user_unconfirmed')) else: flash('Email already registered "{}"'.format(form.email.data)) flash_form_errors(form) return redirect(url_for('index'))
def user_register(): form = RegisterForm() login_form = LoginForm() #print("[+] _______________________[ registering ]") if request.method == 'POST' and form.validate(): user = User.objects(email=form.email.data).first() if user is None: new_user = User(email=form.email.data, password=form.password.data, profile=form.profile.data).save() send_confirmation_email(new_user) flash('Confirmation email sent to "{0}"'.format(form.email.data)) login_user(new_user) return redirect(url_for('user_unconfirmed')) else: flash('"{}" email has already been registered'.format( form.email.data)) #print("[+] _______________________[ user not added ]") return render_template('index.html', registration_form=form, login_form=login_form) return redirect(url_for('index'))
def user_resend(): send_confirmation_email(current_user) flash('Confirmation email sent to "{0}"'.format(current_user.email)) return redirect(url_for('user_unconfirmed'))
def user_resend(): send_confirmation_email(current_user) flash( 'A new confirmation code was sent to {}, please verify your email to continue' .format(current_user.email)) return redirect(url_for('user_unconfirmed'))