def signup(): signup_form = SignupForm() if signup_form.validate_on_submit(): email = signup_form.email.data password = signup_form.password.data user_doc = get_user(email).to_dict() if user_doc is None: password_hash = generate_password_hash(password) user_data = UserData(email, password_hash) user_put(user_data) user = UserModel(user_data) login_user(user) flash('Welcome to our app', 'success') return redirect(url_for('panel')) else: signup_form.email.errors.append('User already exists') context = { 'signup_form': signup_form, } return render_template('signup.html', **context)
def signup(): form = SignupForm() context = { 'form': form } if request.method == 'POST': username = form.username.data password = form.password.data password2 = form.password2.data if form.check_password(password, password2): user_doc = get_user(username) if user_doc.to_dict() is None: user_data = UserData( username=username, password=generate_password_hash(password) ) user_put(user_data) user = UserModel(user_data) return redirect(url_for('auth.login')) else: flash('User already exists.') else: flash('Passwords didn\' match.') return render_template('signup.html', **context)
def signup(): if current_user.is_authenticated: return redirect(url_for('user.meal_plan')) form = SignupForm() if request.method == "POST" and form.validate_on_submit(): fname = form.fname.data lname = form.lname.data email = form.email.data password = form.password.data rpassword = form.rpassword.data if password == rpassword: result = populate_database.insertUser({'fname':fname, 'lname':lname,\ 'email':email,'password':password}) if result == True: # flash a message to the user flash('Sign up successful.', 'success') return redirect(url_for("user.login")) elif result == False: flash('Email address is already associated with an account', 'danger') else: flash('Database connection error', 'danger') else: flash('Passwords does not match', 'danger') return render_template("sign_up.html", form=form)
def signup(): search = SearchForm() if request.method == 'POST' and search.validate_on_submit(): return redirect((url_for('search_page', searchQuery=search.searchParam.data))) if session.get('logged_in') == True: return redirect(url_for('index')) form = SignupForm() if form.validate_on_submit(): name = form.restaurant_name.data email = form.restaurant_email.data phone = form.restaurant_phone.data zipcode = form.restaurant_zipcode.data address = form.restaurant_street.data + form.restaurant_city.data + form.restaurant_state.data new_seller = seller(seller_name=name, seller_email=email, seller_phone=phone, seller_zipcode=zipcode, seller_address=address) new_seller.set_password(form.restaurant_password.data) db.session.add(new_seller) db.session.commit() session["user_id"] = new_seller.seller_id session["logged_in"] = True return redirect(url_for('index')) return render_template('signup.html', title='Sign Up', form=form, search=search)
def signup(): form = SignupForm() if form.validate_on_submit(): flash('Signup requested for user {}, remember_me={}'.format( form.full_name.data, form.email.data)) return redirect('/profile') return render_template('signup.html', title='Signup', form=form)
def login(): form = SignupForm() if request.method == 'GET': return render_template('login.html', form=form) elif request.method == 'POST': if form.validate_on_submit(): # find user in database user=User.query.filter_by(email=form.email.data).first() if user: # hash password password = form.password.data # verify password against hash if sha256_crypt.verify(password, user.password): # log user into app session login_user(user) return redirect(url_for('index')) # if password does not match hash else: error = "Wrong password" return render_template('login.html', form=form, error=error) # user does not exist in database else: error = "User doesn't exist. Please sign up" return render_template('login.html', form=form, error=error) # if form doesn't validate else: error = "Form didn't validate" return render_template('login.html', form=form, error=error)
def register(): form = SignupForm() if request.method == 'GET': return render_template('signup.html', form=form) elif request.method == 'POST': if form.validate_on_submit(): # search if email already exists if User.query.filter_by(email=form.email.data).first(): error = "Email address already exists" return render_template('signup.html', form=form, error=error) # create user if user does not exist in database else: password = form.password.data # safely store hashed password hash_password = sha256_crypt.hash(password) newuser = User(form.email.data, hash_password) db.session.add(newuser) db.session.commit() flash('Thanks for registering!') return redirect(url_for('login')) # if form doesn't validate else: error = "Form didn't validate" return render_template('signup.html', form=form, error=error)
def signup(): form = SignupForm() if form.validate_on_submit(): if User.query.filter_by(email=request.form['email']).first(): flash('This email is already in use') elif User.query.filter_by(username=request.form['username']).first(): flash('This username is already taken') elif len(str(request.form['password'])) < 8: flash('Password is too short') else: highscore = Highscore(0, 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0) user = User(username=request.form['username'], email=request.form['email'], plaintext_password=request.form['password']) highscore.users.append(user) db.session.add(highscore) db.session.commit() session['logged_in'] = True session['username'] = user.username session['deathalltime'] = highscore.deathalltime session['deathlastmonth'] = highscore.deathlastmonth session['deathlastweek'] = highscore.deathlastweek session['gamesalltime'] = highscore.gamesalltime session['gameslastmonth'] = highscore.gameslastmonth session['gameslastweek'] = highscore.gameslastweek session['rating'] = highscore.raiting session['ratingmonth'] = highscore.raitingmonth session['ratingweek'] = highscore.raitingweek session['winsalltime'] = highscore.winsalltime session['winslastmonth'] = highscore.winslastmonth session['winslastweek'] = highscore.winslastweek highscores = Highscore.query.all() set_positions(highscores, highscore) return redirect('/') return render_template('signup.html', form=form)
def signup(): print('signup') form2 = SignupForm() form = LoginForm() error = '' if request.method == 'POST': print(form2.validate()) if form2.submit.data and form2.validate_on_submit(): name = form2.username.data emailid = form2.emailid.data password = form2.password.data # password = password.encode('utf-8') import hashlib, uuid salt = uuid.uuid4().hex # salt = salt.encode('utf-8') hashed_password = hashlib.sha256((salt+password ).encode('utf-8')).hexdigest() print(name,emailid,hashed_password) if(name and emailid and hashed_password): error = createNewUser(name,emailid,hashed_password,salt) # name=name else: error = "Don't have sufficient field data!" return render_template('index.html', form2=form2 , form=form, error = error)
def profile(): myform = SignupForm() if request.method == "POST": if myform.validate_on_submit(): first = myform.firstname.data last = myform.lastname.data gen = myform.gender.data email = myform.email.data loc = myform.location.data bio = myform.biography.data pic = request.files['file'] now = datetime.now() signdate = now.strftime("%B") + " " + str(now.day) + ", " + str( now.year) photoname = secure_filename(pic.filename) pic.save(os.path.join(app.config['UPLOAD_FOLDER'], photoname)) user = UserProfile(first, last, gen, email, loc, bio, signdate, photoname) db.session.add(user) db.session.commit() flash("Profile Successfully Created", "success") return redirect("/") else: flash("Failed to create profile", "danger") return render_template('profile.html', myform=myform)
def signup(): signup_form = SignupForm() context = {"signup_form": signup_form} if signup_form.validate_on_submit(): username = signup_form.username.data email = signup_form.email.data password = signup_form.password.data user_doc = get_user(email) if user_doc.to_dict() is None: password_hash = generate_password_hash(password) user_data = UserData(username, email, password_hash) user_put(user_data) user = UserModel(user_data) login_user(user) flash("Bienvenido") return redirect(url_for("hello")) else: flash("El usuario ya existe") return render_template("signup.html", **context)
def signup(): # # Disable access to login page if user is already logged in. if current_user.is_authenticated: flash("You are already signed up!") return redirect(url_for('index')) form = SignupForm( ) # created an instance of SignupForm() and called it "form" # Check if email was used for another account # Checks if form fields are filled # if it is, create a new user with provided credentials if request.method == 'POST': if form.validate_on_submit(): if User.query.filter_by(email=form.email.data).first(): flash("This email is already in use") return redirect(url_for('users.signup')) new_user = User(first_name=form.first_name.data, last_name=form.last_name.data, email=form.email.data, password=form.password.data, wca_id=None, dob=None) new_user.credentials = 1 db.session.add(new_user) db.session.commit() flash("You have successfully signed up! Please log in!") return redirect(url_for('index')) else: return render_template('signup.html', form=form) return render_template('signup.html', form=form)
def signup(): """ User sign-up page. GET requests serve sign-up page. POST requests validate form & user creation. """ if current_user.is_authenticated: print('Checking if current user is_authenticated') print('current_user :'******'newsfeed')) form = SignupForm() # if request.method == 'POST': # #This is to help store files in b'' and save directly to db # pic = request.files['photo'].read() if form.validate_on_submit(): print('validating...') user = User(name=form.name.data, email=form.email.data) #, photo=pic user.set_password(form.password.data) db.session.add(user) db.session.commit() flash('Account Succefully Created!') login_user(user) return redirect(url_for('newsfeed')) return render_template('sign-up.html', title='Create an Account.', form=form)
def signup(): if not current_user.is_anonymous: return redirect(url_for('home.index')) form = SignupForm() if form.validate_on_submit(): email = form.email.data.lower() user = User.query.filter_by(email=email).first() if user is not None: logging.error("User %s already exists" % (email)) return render_template( 'signup.html', signup_form=form, error="Account already exists") user = User(email=email, password=form.password.data) db.session.add(user) db.session.commit() login_user(user) return redirect(url_for('home.index')) return render_template('signup.html', signup_form=form)
def signup_login(): if current_user.is_authenticated: #do not show the signup/login page to users who are already logged in return redirect(url_for('index')) form1 = SignupForm() form2 = LoginForm() #if user submits signup form if form1.submitSignup.data and form1.validate_on_submit(): user = User(username=form1.username.data, email=form1.email.data) user.set_password(form1.password.data) #store hash of user's password db.session.add(user) db.session.commit() flash('Thanks for signing up, you can now log in') return redirect(url_for('signup_login')) #if user submits login form if form2.submitLogin.data and form2.validate_on_submit(): user = User.query.filter_by(username=form2.username.data).first() #if provided username doesnt exist or incorrect password if user is None or not user.check_password(form2.password.data): flash('Invalid username or password') return redirect(url_for('signup_login')) #else login successful login_user(user) #store the logged in user in current_user next_page = request.args.get('next') #send user to their intended page, if they were redirected due to not logged in if not next_page or url_parse(next_page).netloc != '': next_page = url_for('index') return redirect(next_page) #return user to whatever page they were visiting, but now logged in return render_template('signuplogin_page.html', signForm=form1, logForm=form2)
def signup(request): if request.user.is_authenticated(): return HttpResponseRedirect(reverse('my_account')) if request.method == "POST": login_form = CustomLoginForm() consumer_form = SignupForm(request.POST) if consumer_form.is_valid(): consumer_first_name = consumer_form.cleaned_data.get('first_name') consumer_last_name = consumer_form.cleaned_data.get('last_name') consumer_email = consumer_form.cleaned_data.get('email') consumer_password = consumer_form.cleaned_data.get('password') consumer_retype_password = consumer_form.cleaned_data.get('retype_password') consumer_username = consumer_form.cleaned_data.get('username') user = User.objects.create_user(consumer_username, consumer_email, consumer_password) user.first_name = consumer_first_name user.last_name = consumer_last_name user.save() consumer = Consumer(user = user) consumer.phone = consumer_form.cleaned_data.get('phone') consumer.save() user = authenticate(username=consumer_username, password=consumer_password) login(request, user) return HttpResponseRedirect(reverse('index')) else: consumer_form = SignupForm() login_form = CustomLoginForm() return render(request, "signup.html", {'customer_form': consumer_form, 'form':login_form})
def signup_post(): signupForm = SignupForm() if signupForm.validate(): #Verify that the user doesn't exist in the DB user = User.query.filter_by(email=signupForm.email.data).first() if user: flash('El email ya se encuentra registrado.') return redirect(url_for('auth.signup')) user = User.query.filter_by(username=signupForm.username.data).first() if user: flash('El usuario ya se encuentra registrado.') return redirect(url_for('auth.signup')) totalAmount = 0 #Create the object User to store it in the DB new_user = User(email=signupForm.email.data, username=signupForm.username.data, password=generate_password_hash( signupForm.password.data, method='sha256')) #Save both records in the DB db.session.add(new_user) db.session.commit() #Create the object UserConfiguration to store it in the BD new_user_config = UserConfiguration(spend_limit=totalAmount, warning_percent=75, hide_amounts=0, user_id=new_user.id) db.session.add(new_user_config) db.session.commit() #Create the object Saving to store it in the DB, by default is ARS (Pesos) with amount 0 new_user_default_saving = Saving(user_id=new_user.id, currency_id=1, amount=0) db.session.add(new_user_default_saving) db.session.commit() #Send Slack Message notifying the new registration try: wsChannel = 'CSWSV4LLF' #walletsentinel channel sendNewUserSlackMessage(wsChannel, signupForm.username.data) except: print('Ha ocurrido un error al enviar la notifiación a slack..') return redirect(url_for('auth.login')) else: return render_template('signup.html', form=signupForm)
def signup(): form = SignupForm() if form.validate_on_submit(): user = models.User(username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() return redirect(url_for('index')) return render_template('signup.html', title='Sign Up', form=form)
def signup(): form = SignupForm() # vaildate signup form if form.validate_on_submit(): # display sucessful sign up message flash('{} has signed up using email {} and password {}'.format( form.username.data, form.email.data, form.password.data)) return redirect(url_for('index')) return render_template('signup.html', title='Sign Up', form=form)
def signup(): signup_form = SignupForm() if signup_form.validate_on_submit(): user = User(first_name=signup_form.first_name.data, last_name=signup_form.last_name.data, \ email=signup_form.email.data, image_url=signup_form.image_url.data) user.save() user.set_password(password=signup_form.password.data) login_user(user, remember=True) return redirect(url_for('dashboard')) return render_template('signup.html', signup_form=signup_form, login_form=LoginForm())
def signup(): form = SignupForm() if form.validate_on_submit(): user = User(email= form.email.data, username= form.username.data, password = form.password.data) db.session.add(user) db.session.commit() flash('Welcome, {}!'.format(user.username)) return redirect(url_for('login')) return render_template("signup.html", form=form)
def signup(): if current_user.is_authenticated: return redirect(url_for('home')) form = SignupForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) db.session.add(user) db.session.flush() login_user(user) return redirect(url_for('home')) return render_template('sign_up.html',form=form)
def index(): """ Renders the backend of the index page and returns template """ form = SignupForm() # If the form has been submitted if form.validate_on_submit(): u_views.run_signup_form(form) return redirect('/#signup') return render_template("index.html", form=form)
def login(request): form = SignupForm(request.POST) if form.is_valid(): password = form.cleaned_data['password'] email = form.cleaned_data['email'] username = User.objects.filter(email=email).first() user = authenticate(username=username.username, password=password) if user: auth_login(request, user) return HttpResponseRedirect(reverse('index')) return render(request, 'login.html', {'form': form})
def signup(): if current_user.is_authenticated: return redirect(url_for('index')) form = SignupForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash(_('Congratulations! you signed up successfully')) return redirect(url_for('login')) return render_template('signup.html', title='Sign Up', form=form)
def index(): signup_form = SignupForm() if signup_form.validate_on_submit(): first_name = signup_form.first_name.data last_name = signup_form.last_name.data email = signup_form.email.data send_to_google(first_name, last_name, email) print('\n', first_name, last_name, email, '\n') return render_template('index.html', signup_form=signup_form)
def signup(): if current_user.is_authenticated: return redirect(url_for("index")) form = SignupForm() if form.validate_on_submit(): user = User(email=form.email.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash("Congratulations, you are now a registered user!") return redirect(url_for("login")) return render_template("signup.html", title="Sign up", form=form)
def signup(): form = SignupForm() if form.validate_on_submit(): new_user = User(first_name=form.first_name.data, last_name=form.last_name.data, place=form.place.data, email=form.email.data, password=form.password.data) new_user.save() login_user(new_user, remember=True) return redirect('/') return render_template('signup.html', form=form)
def signup(): form = SignupForm() if form.validate_on_submit(): error, user_id = signupValidation(form) if not error: # i.e. if no errors, send to journal landing session['user_id'] = user_id return redirect(url_for('journal_land')) else: return render_template('signup.html', form=form, error=error) else: return render_template('signup.html', form=form)
def signup(): """ User sign-up page GET -> requests serve sign-up page POST -> requests validate form & user creation """ form = SignupForm() if form.validate_on_submit(): existing_user = User.query.filter_by(email=form.email.data).first() if existing_user is None: user = User(name=form.name.data, email=form.email.data, website=form.website.data, created_on=datetime.now(), role='user') user.set_password(form.password.data) user.update_last_login(datetime.now()) db.session.add(user) db.session.commit() current_app.logger.info('New {} registered'.format(user)) #login_user(user) return redirect(url_for('dashboard.home')) error = 'Un usuario ya utiliza esa dirección email.' flash(error) current_app.logger.error(error) # Check if user already login #if current_user.is_authenticated: # error = 'User already logged in. Sign out first.' # flash(error) # current_app.logger.error(error) # return redirect(url_for('dashboard.home')) #else: # return render_template('auth/signup.html',form=form) if not current_user.is_authenticated: error = 'Contacta con soporte para que te creen una cuenta.' flash(error) current_app.logger.error('An user try to signup.') return redirect(url_for('auth.login')) elif current_user.is_admin(): return render_template('auth/signup.html', form=form) else: error = 'No tienes permisos para hacer eso.' flash(error) current_app.logger.error( 'User {} try to signup a new account'.format(current_user)) return redirect(url_for('dashboard.home'))
def signup(): # make sure user is not logged in if current_user.is_authenticated: return redirect(url_for('index')) form = SignupForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash('Welcome to Boring Twitter') return redirect(url_for('login')) return render_template('signup.html', title='Sign up', form=form)
def signup(): form = SignupForm(request.form) if request.method == 'POST' and form.validate(): user = User(username=form.name.data, email=form.email.data) try: db.session.add(user) db.session.commit() flash('You are now a registered user!') return redirect(url_for('index')) except IntegrityError: db.session.rollback() flash('ERROR! Unable to register {}. Please check your details are correct and resubmit'.format(form.email.data), 'error') return render_template('signup.html', form=form)
def signup(): """ Signup page, requires post for form """ form = SignupForm() if request.method == 'GET': return render_template('signup.html', form=form) else: if form.validate_on_submit(): user = UserHandler.create_user(form) login_user(user, remember=True, force=True) return redirect(url_for('base.home')) raise Unauthorized()
def signup(): form = SignupForm() if 'email' not in session: return render_template('no_permis.html') else: if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.nom.data, form.cognom.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() return redirect(url_for('index')) elif request.method == 'GET': return render_template('signup.html', form=form)
def signup(): form = SignupForm() try: if form.validate_on_submit(): Signup_Page.signup_clicked(form.account.data, form.pwd.data, form.email.data) flash("Sign-up successed.") return redirect('/login') except ValueError: abort(401) except psycopg2.DatabaseError as dberror: flash(dberror.pgerror) return redirect('/signup') return render_template('signup.html', title = 'Sign Up', form = form)
def signup(request): if request.method == 'POST': form = SignupForm(request.POST) if form.is_valid(): user = User.objects.create_user( username=form.cleaned_data['username'], first_name=form.cleaned_data['first_name'], last_name=form.cleaned_data['last_name'], email=form.cleaned_data['email'], role=form.cleaned_data['role'], password=form.cleaned_data['password'], ) return HttpResponseRedirect('/registered/') else: form= SignupForm() return render(request,'signup.html',{'form':form},context_instance=RequestContext(request))
def signup(): if g.user: return redirect(url_for(".index")) form = SignupForm(csrf_enabled=False) if form.validate_on_submit(): u = User.create(passwd=form.password.data, email=form.email.data) if u: g.user = u session['user_id'] = g.user.id return redirect(url_for(".index")) else: flash("An account already exists with that username.") return render_template("default/signup.html", form=form)
def register(): form = SignupForm(request.form, csrf_enabled=False) if form.validate_on_submit(): #form.validate_on_submit(): print("validated or post") fname = form.fname.data lname = form.lname.data email = form.email.data password = form.pass_conf.data user = User(fname, lname, email, password) db.session.add(user) db.session.commit() print("User added") return redirect('/') print("user not added") return render_template('register.html', form = form)
def signup(): form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.firstname.data, form.lastname.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email return redirect(url_for('profile')) elif request.method == 'GET': return render_template('signup.html', form=form)
def signup(): form = SignupForm() if form.validate_on_submit(): userlist = User.query.filter_by(email = form.email.data) if userlist.count() > 0: print("Can't signup user with already existing e-mail " + form.email.data + '!') flash( "Can't register you because this e-mail already registered!" ) return redirect( '/signup' ) user = User(form.first_name.data, form.second_name.data, form.patronymic.data, form.email.data, form.password.data, ROLE_USER, STATUS_READ_ONLY) db.session.add(user) db.session.commit() flash('Your registration has finished! You can login using your e-mail address and password') return redirect('/') return render_template('signup.html', completed=False, form=form, authenticated=False)
def register(): form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('register.html', form=form) else: password = form.password.data email = form.email.data newuser = User(email, password) msg = Message('hie', sender='*****@*****.**', recipients=['*****@*****.**']) msg.body = """ From: %s """ % (form.email.data) mail.send(msg) db.session.add(newuser) db.session.commit() if current_user: return redirect(url_for('dashboard')) elif request.method == 'GET': return render_template('register.html', form=form)
def signup(): from app.forms import SignupForm form = SignupForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data.lower()).first() if user is not None: form.email.errors.append("The Email address is already taken.") return render_template("signup.html", form=form) newuser = User(form.firstname.data, form.lastname.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session["email"] = newuser.email return redirect(url_for("login")) return render_template("signup.html", form=form)
def signup(): """ Route for url: server/signup/ """ form = SignupForm() if request.method == 'GET': return render_template('signup.html', form = form) if request.method == 'POST': if form.validate(): cur = get_cursor() pw_hash = hash_password(form.password.data) add_user(cur, form, pw_hash) send_registration_email(form) session['username'] = form.username.data flash('Welcome to BuildersRecords! Thank you for creating an account with us.') return redirect(url_for('home')) flash('There were problems creating your account.') return render_template('signup.html', form = form)
def signup(): form = SignupForm() if 'email' in session: return redirect(url_for('profile')) if request.method == 'POST': if form.validate() == False: return render_template('register.html', form=form) else: newuser = User(form.firstname.data, form.lastname.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email return redirect(url_for('profile')) return "[1] Create a new user [2] sign in the user [3] redirect to the user's profile" elif request.method == 'GET': return render_template('register.html', form=form)
def index(): #TODO: Add chosen to carrier list form = SignupForm() registered = False if form.validate_on_submit(): carrier = form.carrier.data phone_number = int(form.phone_number.data) print(phone_number) if add_user(carrier, phone_number): return redirect(url_for('main.confirm', carrier=carrier, number=phone_number)) try: phone_number = int(form.phone_number.data) except: phone_number = None if phone_number and User.query.get(phone_number): registered = True return render_template('index.html', form=form, registered=registered)
def signup(): form = SignupForm(next=request.args.get("next")) if form.validate_on_submit(): user = User() form.populate_obj(user) user.save() # Flask-Login login_user(user) # Flask-principal identity_changed.send(current_app._get_current_object(), identity=Identity(user.username)) flash(u"欢迎, %s" % user.username, "successfully") next_url = form.next.data if not next_url or next_url == request.path: next_url = url_for('user.posts', username=user.username) return redirect(next_url) return render_template("account/signup.html", form=form)
def register(): if 'email' not in session: form = SignupForm(request.form, csrf_enabled=False) if form.validate_on_submit(): #form.validate_on_submit(): print("validated or post") fname = form.fname.data lname = form.lname.data email = form.email.data password = form.pass_conf.data user = User(fname, lname, email, password) db.session.add(user) db.session.commit() print("User added") return redirect('/') print("user not added") return render_template('register.html', form = form) else: user = User.query.filter_by(email = session['email']).first() return redirect('/api/user/'+str(user.user_id)+'/wishlist')
def signup(): template = env.get_template('user/signup.html') form = SignupForm(request.POST) if request.method == 'POST': if form.validate(): try: user = User.get(User.mail == form.mail.data) except DoesNotExist: new_user = User.create( mail=form.mail.data, user_password=User.encode_password(form.password.data), first_name=form.first_name.data, last_name=form.last_name.data, nickname=form.nickname.data, ) app.flash('Well done! Now you can log in') redirect('/login') else: app.flash( 'User with such an email already exists', category='info', ) return template.render(form=form)
from app import app, login_manager