def register(): statsd.increment('api_calls.register') form = SignupForm(request.form) logger.info(request.form) if not form.validate(): msg = { 'success': False, 'msg': form.errors} return jsonify(msg) user = session.query(Person).\ filter(Person.email == form.email.data ).first() if user: msg = { 'success': False, 'msg': user.email + ' is already registered!', 'parameter': 'email', } return jsonify(msg) u = Person(form) session.add(u) session.commit() try: pm = PostMonkey(apikey=MC_APIKEY, timeout=10) pm.listSubscribe( id=MC_LISTID, email_address=form.email.data) except MailChimpException, e: app.logger.error(str(e))
def signup(): form = SignupForm() #if 'userid' in session: # return redirect(url_for('set_profile')) if request.method == 'POST': if form.validate() == False: return render_template('signup.html',form = form) else: verification_code = random.randint(1,10000) userlogin = Peer_UserStatus_Model(form.username.data, form.email.data, form.password.data,verification_code,0) db.session.add(userlogin) db.session.commit() usersignup = User_Info_Model(form.username.data,'offline') db.session.add(usersignup) db.session.commit() session['userid'] = userlogin.username session['email'] = userlogin.email mail(str(verification_code)) return render_template('verification_mail_confirmation.html') elif request.method == 'GET': return render_template('signup.html',form = form)
def signup(): form = SignupForm() if g.is_logged_in is True: return redirect(url_for('profile')) if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.username.data, form.firstname.data, form.lastname.data, form.email.data, form.password.data, str(uuid.uuid1())) db.session.add(newuser) db.session.commit() session['email'] = newuser.email msg = Message('Confirm your email address - Flaskapp', sender='*****@*****.**', recipients=[newuser.email]) msg.body = """ Please follow the link below to verify your account: localhost:5000/email_confirmation/%s """ %(newuser.uuid) mail.send(msg) return redirect(url_for('profile')) elif request.method == 'GET': return render_template('signup.html', form=form)
def create_user(): form = SignupForm() if form.validate() is False: return make_response(jsonify(form.errors), 400) else: if (User.query.filter_by(email=form.email.data).count() > 0): return Response(dictionary()["email_already_exists"], status=400, mimetype='application/json') try: confirmation_code = _gen_confirmation_code(form.email.data) user = User( fullname=form.fullname.data, email=form.email.data, password=sha512(form.password.data), confirmation_code=confirmation_code, agree_mailer=form.agree_mailer.data ) db.session.add(user) db.session.commit() except: return Response(dictionary()["Sorry, an unexpected error has occured. Please try again"], status=500, mimetype='application/json') user_srl = user.serialize() send_confirmation(user) message = dictionary()["check_your_inbox"] + ' ' + user.email return Response(message, status=200, mimetype='application/json')
def signup(): form = SignupForm() if request.method == "POST": if form.validate() == False: return render_template("signup.html", form=form) else: g.newuser = User( form.firstname.data, form.lastname.data, form.phone.data, form.country_id.data, form.email.data, form.password.data, ) db_session.add(g.newuser) db_session.commit() session["lastname"] = g.newuser.lastname session["firstname"] = g.newuser.firstname session["phone"] = g.newuser.phone session["country_id"] = g.newuser.country_id if g.newuser.country_id == 1: session["country_id"] = "Nigerian" else: session["country_id"] = "Foreigner" session["email"] = g.newuser.email return redirect(url_for("wallet")) elif request.method == "GET": return render_template("signup.html", form=form)
def register(): form = SignupForm() if request.method == 'POST' and form.validate(): user_per_email = User.objects(email=form.email.data) user_per_username = User.objects(username=form.username.data) if user_per_email: form.errors['email'] = ['Email is already taken.'] elif user_per_username: form.errors['username'] = ['Username is already taken.'] else: user = User(email=form.email.data, username=form.username.data) user.set_password(form.password.data) user.save() login_user(user) analytics.identify(str(user.id), {'email': str(user.email)}) analytics.track(str(user.id), 'Registered (srv)') return redirect('/data') for field, errors in form.errors.items(): # type(errors) for error in errors: flash(u"Error in %s - %s" % ( getattr(form, field).label.text, error)) return render_template('users/user.html', form=form)
def register(): form = SignupForm() if request.method == 'POST': if form.validate() == False: print(form.validate()) return render_template('register.html', form=form) else: newuser = User(form.nickname.data, form.password.data) db.session.add(newuser) db.session.commit() os.mkdir(os.path.join(UPLOAD_DIR, secure_filename(newuser.nickname))) flash(u'Zarejestrowano poprawnie.', 'success') return redirect(url_for('login')) elif request.method == 'GET': 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: return 'success' return render_template('signup.html',form=form)
def signup(): form = SignupForm(request.form) if request.method == "POST" and form.validate(): user = User() form.populate_obj(user) user.password = hash_str(form.password.data) user.save() return redirect('/user') return render_template('signup.html', form=form)
def signup(): print 'good' form = SignupForm() if 'username' in session: return redirect(url_for('dashboard')) if request.method == 'POST': print 'better' if form.validate() == False: print 'is it false?' print form return render_template('signup.html', form=form) else: newuser = User(form.firstname.data, form.lastname.data, form.username.data, form.password.data, form.email.data) # add_follower = Follow(username, session['username'], followed.id, follower.id) db.session.add(newuser) # db.session.add(add_follower) db.session.commit() session['username'] = newuser.username if not os.path.exists("/Users/developeraccount/Desktop/Lens/lens/src/static/accounts/%s" % session['username']): os.mkdir("/Users/developeraccount/Desktop/Lens/lens/src/static/accounts/%s" % session['username']) if not os.path.exists("/Users/developeraccount/Desktop/Lens/lens/src/static/accounts/%s/profile_picture" % session['username']): os.mkdir("/Users/developeraccount/Desktop/Lens/lens/src/static/accounts/%s/profile_picture" % session['username']) if not os.path.exists("/Users/developeraccount/Desktop/Lens/lens/src/static/accounts/%s/cover_picture" % session['username']): os.mkdir("/Users/developeraccount/Desktop/Lens/lens/src/static/accounts/%s/cover_picture" % session['username']) url = 'http://invatar0.appspot.com/svg/%s%s.jpg?s=256' % (form.firstname.data[:1], form.lastname.data[:1]) # response = requests.get(url) # print response.content # with open('/Users/developeraccount/Desktop/Roadbeam/roadbeam/src/static/accounts/%s/profile_picture/profile.jpg' % session['username'], 'wb') as out_file: # out_file.write(response.content) # del response # urllib.urlretrieve(url, '/Users/developeraccount/Desktop/Roadbeam/roadbeam/src/static/accounts/%s/profile_picture/profile.jpg' % session['username']) response = requests.get(url) if response.status_code == 200: f = open('/Users/developeraccount/Desktop/Lens/lens/src/static/accounts/%s/profile_picture/profile.jpg' % session['username'], 'wb') f.write(response.content) f.close() session['completeprofile'] = newuser.username # threading.Thread(target=profileSetup, args=(session['username'], db)).start() return redirect(url_for('verify')) # return redirect(url_for('somedetails')) # do this if verify email sucks elif request.method == 'GET': return render_template('signup.html', form=form)
def company_signup(): """Provide HTML form to adda new student record.""" form = SignupForm(request.form) if request.method == 'POST' and form.validate(): user = User(username = form.username.data, password = generate_password_hash(form.password.data), role = 3) db.session.add(user) db.session.commit() # Success. Send the user back to the full appointment list. return redirect(url_for('company_index')) # Either first load or validation error at this point. return render_template('company/signup.html', form=form)
def signup(): ''' User Sign up page: Very basic email + password sign up form that will also login users. ''' ## Data is used throughout for the jinja2 templates data={ 'active': "signup", # Sets the current page 'loggedin': False # Don't show the logout link } ## Define the SignupForm form = SignupForm(request.form) ## Validate and then create userdata if request.method == "POST": if form.validate(): ## Take form data email = form.email.data password = form.password.data company = form.company.data contact = form.contact.data userdata = { 'username': email, 'email': email, 'password': password, 'company': company, 'contact': contact } ## Create user user = User() result = user.createUser(userdata, g.rdb_conn) ## Check results for success or failure if result == "exists": data['error'] = True data['msg'] = 'User already exists' elif result is not False: stathat.ez_count(app.config['STATHAT_EZ_KEY'], app.config['ENVNAME'] + ' User Signup', 1) print("/signup - New user created") cdata = cookies.genCdata(result, app.config['SECRET_KEY']) data['loggedin'] = True data['msg'] = 'You are signed up' data['error'] = False ## Build response resp = make_response(redirect(url_for('dashboard_page'))) timeout = int(time.time()) + int(app.config['COOKIE_TIMEOUT']) ## Set the cookie secure as best as possible resp.set_cookie('loggedin', cdata, expires=timeout, httponly=True) return resp else: stathat.ez_count(app.config['STATHAT_EZ_KEY'], app.config['ENVNAME'] + ' Failed User Signup', 1) print("/signup - Failed user creation") data['msg'] = 'Form is not valid' data['error'] = True ## Return Signup Page return render_template('signup.html', data=data, form=form)
def add_student(): """Provide HTML form to adda new student record.""" form = SignupForm(request.form) if request.method == 'POST' and form.validate(): user = User(username = form.username.data, password = generate_password_hash(form.password.data), role = 0) db.session.add(user) db.session.commit() flash('Account created! Please send the student you added the password. Thank you! ') # Success. Send the user back to the full appointment list. return redirect(url_for('school_index')) # Either first load or validation error at this point. return render_template('school/add.html', form=form)
def signup(): form = SignupForm() if request.method == 'POST': if not form.validate(): return render_template('signup.html',form=form) else: newperson = Person(form.firstname.data,form.lastname.data,form.email.data,form.password.data) db.session.add(newperson) db.session.commit() session['email']=newperson.email return redirect(url_for('profile')) elif request.method=='GET': return render_template('signup.html',form=form)
def signup(): roles={1:"stu",2:"admin",3:"teacher"} if request.method == 'GET': return render_template('account/signup.html') form = SignupForm(request.form) if form.validate(): usr=form.save() login_user(usr) return redirect("/stu") for fieldName, errorMessages in form.errors.iteritems(): for err in errorMessages: flash(err) return render_template('account/signup.html')
def signup(): form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template("signup.html", form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data ) newuser.save() return "Success!" elif request.method == 'GET': return render_template("signup.html", form=form)
def signup(): form = SignupForm() if request.method == "POST": if form.validate() is False: return render_template('signup.html', form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email return redirect(url_for('home')) elif request.method == "GET": return render_template('signup.html', form=form)
def signin(): form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signin.html', form=form) else: session['username'] = form.username.data return redirect(url_for('profile')) elif request.method == 'GET': return render_template('signin.html', form=form) return render_template('signin.html', form=form)
def signup(): form = SignupForm() if current_user.is_authenticated(): return redirect(url_for('profile')) if request.method == 'POST' and form.validate(): newuser = User(form.email.data, form.password.data) db.session.add(newuser) db.session.commit() login_user(newuser) return redirect(url_for('profile')) # Form does not validate return render_template('signup.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.nickname.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email']=newuser.email return redirect(request.args.get('next') or url_for('index')) elif request.method == 'GET': return render_template('signup.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.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() return 'Success!' elif request.method == "GET": return render_template('signup.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.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email flash('Registration complete. Please, login in system') return redirect('/login') return render_template('signup.html', form=form)
def signup(): form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup_bootstrap.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_bootstrap.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) newuser.set_registration_date(datetime.datetime.now()) db.session.add(newuser) db.session.commit() flash("Sign up successful. Please sign in.") return redirect(url_for('login')) elif request.method == 'GET': return render_template('signup.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() # redirect(url_for('login')) return jsonify({'status':201,'firstname':newuser.firstname,'lastname':newuser.lastname,'username':newuser.email,'message':"User successfully created"}),201,{'Location':url_for('login')} #location : url for new created user elif request.method=='GET': return render_template('signup.html',form=form)
def signup(): form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form = form) else: new_user = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(new_user) db.session.commit() session['uid'] = new_user.user_id return redirect(url_for('user_timeline', uid = session['uid'])) elif request.method == 'GET': return render_template('signup.html', form = form)
def signup(): if "email" in session: return redirect(url_for('home')) form = SignupForm() if request.method =='POST': if not form.validate(): return render_template('signup.html', form=form) else: newUser = User(form.first_name.data, form.last_name.data,form.email.data,form.password.data) db.session.add(newUser) db.session.commit() session['email'] = newUser.email return redirect(url_for('home')) elif request.method == 'GET': return render_template('signup.html',form=form)
def signup(): """The signup action, which either shows the form (GET) or handles the form submission (POST). """ form = SignupForm(request.form) if request.method == 'POST' and form.validate(): existing = User.objects(username=form.username.data).first() if existing == None: user = User(username=form.username.data, \ password=encrypt_password(form.password.data)) user.save() setup_user_in_session(user, session) flash('Thanks for signing up!') return redirect("/") else: flash('That username already exists.') return render_template('signup.html', form=form)
def post(self): if self.current_user and self.get_argument("action", '') == 'email': if self.current_user.role != 'unverify': result = {'status': 'success', 'message': '您的账户已经激活'} self.flash_message(result) else: self.send_register_email(self.current_user) return self.redirect("/account/setting") if self.current_user: return self.redirect_next_url() form = SignupForm(self.request.arguments) if form.validate(): user = form.save() self.set_current_user(user) self.send_register_email(user) return self.redirect_next_url() return self.render("user/signup.html", form=form)
def signup(): if "email" in session: return redirect(url_for("account")) form = SignupForm() if request.method == "POST": if form.validate() == False: return render_template("signup.html", form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session["email"] = newuser.email return redirect(url_for("account")) elif request.method == "GET": return render_template("signup.html", form=form)
def signup(): if 'email' in session: return redirect(url_for('home', _scheme='https', _external=True)) form = SignupForm() if request.method == "POST": if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email return redirect(url_for('home', _external=True, _scheme='https')) elif request.method == "GET": return render_template('signup.html', form=form)
def signup(): if "email" in session: return redirect(url_for("home")) form = SignupForm() if request.method == "POST": if form.validate() == False: return render_template("signup.html", form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session["email"] = newuser.email return redirect(url_for("home")) elif request.method == "GET": return render_template("signup.html", form=form)
def signup(): if 'email' in session: return redirect(url_for('home')) form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template("signup.html", form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email flash('You signed up successfully', 'info') return redirect(url_for('home')) elif request.method == 'GET': return render_template("signup.html", form=form)
def signup(): if 'email' in session: return redirect(url_for('home')) form = SignupForm() if request.method == "POST": if form.validate() == False: return render_template('signup.html', form=form) else: #create new user newuser = User(form.name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email return redirect(url_for('home')) elif request.method == "GET": 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 not form.validate(): 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 'email' in session: return redirect(url_for('profile')) if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: addUser(None, form.username.data, form.email.data.lower(), form.password.data, form.location.data, "", "Normal", form.lng.data, form.lat.data) session['email'] = form.email.data.lower() return redirect(url_for('profile')) elif request.method == 'GET': return render_template('signup.html', form=form)
def signup(): if 'email' in session: return redirect(url_for('home')) form = SignupForm() if request.method == "GET": return render_template('signup.html', form=form) elif request.method == "POST": if not form.validate(): return render_template('signup.html', form=form) else: user = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) try: db.session.add(user) db.session.commit() session['email'] = user.email return redirect(url_for('home')) except Exception as e: return "Something is wrong with the DB: {error}".format( error=e)
def signup(): error = None form = SignupForm(request.form) if request.method == 'POST' and form.validate(): username = form.username.data email = form.email.data password = form.password.data #get data and store in a variable post dup = User.query.filter_by(email=form.email.data).first() if dup.email == form.email.data: error = 'Email already registered' return render_template('signup.html', form=form, error=error) else: post = User(username=username, email=email, password=password) #add post variable to db db.session.add(post) db.session.commit() flash('successfuly registered') #return redirect(url_for('login')) return render_template('signup.html', form=form, error=error)
def signup(): form = SignupForm(request.form) if request.method == "POST" and form.validate(): username = form.username.data password = form.password.data existing_user = User.query.filter_by(username=username).first() if existing_user: form.username.errors.append( "User with that username already exists") else: user = User(username, password) db.session.add(user) db.session.commit() login_user(user) return redirect(url_for("list_transactions")) return render_template("signup.html", form=form)
def signup(): form = SignupForm(request.form) if request.method == 'POST' and form.validate(): if not validate_email(form.email.data) and form.validate: return render_template('signup.html',form=form, message='The email provided is not valid') if existEmail(form.email.data) and form.validate: return render_template('signup.html',form=form, message='The email already exist!') if existUsername(form.username.data): return render_template('signup.html',form=form, message='The username already exist!') user = models.User(str(uuid.uuid4()),form.firstname.data, form.lastname.data, form.email.data, form.username.data, form.password.data,datetime.datetime.now()) models.db.session.add(user) models.db.session.commit() return redirect('/login') return render_template('signup.html', form=form)
def signup(): try: if 'email' in session: return redirect(url_for('home')) form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email return redirect(url_for('home')) elif request.method == "GET": return render_template('signup.html', form=form) except: return redirect(url_for('login'))
def signup(): form = SignupForm() if not form.is_submitted(): return render_template('signup.html', form=form) if not form.validate(): return render_template('signup.html', form=form), 400 try: safe_auth0_call(auth0_db.signup, client_id=AUTH0_CLIENT_ID, connection=AUTH0_CONNECTION, email=form.email.data, password=form.password.data) except Auth0Error as err: form.email.errors = [err.message] form.password.errors = [err.message] return render_template('signup.html', form=form), 400 return redirect('/login')
def signup(): form = SignupForm() if 'email' in session: return redirect(url_for('post_event')) if request.method == 'POST': if form.validate() == False: flash('All fields are required') 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) flash("Registration successful") db.session.commit() session['email'] = newuser.email return redirect(url_for('signin')) elif request.method == 'GET': return render_template('signup.html', form=form)
def signup(): if 'email' in session: return redirect(url_for('home')) form = SignupForm() # Check for GET / POST Requests. if request.method == 'POST': if not form.validate(): return render_template('signup.html', form=form) # Form has valid data, so persist to the Database. new_user = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(new_user) db.session.commit() # Start User Session. session['email'] = new_user.email return redirect(url_for('home')) elif request.method == 'GET': return render_template('signup.html', form=form)
def signup(): #Authentication from scratch for a deeper understanding #For rapid development, use the Flask login extension if "email" in session: return redirect(url_for("home")) form = SignupForm() if request.method == "POST": if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session["email"] = newuser.email return redirect(url_for("home")) elif request.method == "GET": return render_template('signup.html', form=form)
def signup(): if 'email' in session: return redirect(url_for('home')) form = SignupForm() #SignupForm class imported from forms.py if request.method == 'POST': if form.validate( ) == False: # Check if any validation errors were captured return render_template("signup.html", form=form) # Will return form with errors else: # If no errors are found, user is added to database newuser = User(form.first_name.data, form.last_name.data, form.email_unique.data, form.password.data) db.session.add(newuser) db.session.commit() session[ 'email'] = newuser.email # Initiate session object with 'email key' return redirect(url_for('home')) elif request.method == 'GET': return render_template("signup.html", form=form)
def signup(): if 'email' in session: # used to avoid login page if user already login return redirect(url_for('home')) form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: # adding the new user to db newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) #fetch input data from form using data attribute db.session.add(newuser) db.session.commit() #initiating a new session session['email'] = newuser.email return redirect(url_for('home')) elif request.method == 'GET': return render_template('signup.html', form=form) return 'Else'
def signup(): if 'account_name' in session: return redirect(url_for('home')) form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: new_household_account = household_account( form.account_name.data, form.account_password.data) db.session.add(new_household_account) db.session.commit() session['account_name'] = new_household_account.account_name return redirect(url_for('home')) elif request.method == "GET": return render_template('signup.html', form=form) return render_template("signup.html", form=form)
def signup(): colours = ['Red', 'Blue', 'Black', 'Orange'] if 'email' in session: return redirect(url_for('home')) form = SignupForm() if request.method == "POST": if form.validate() == False: print("here-->1") return render_template('signup.html', form=form) else: signup_result = ln.singup(form.first_name.data, form.last_name.data, form.username.data, form.password.data, form.email.data, form.food.data, form.exer.data) session['email'] = form.email.data return redirect(url_for('home')) elif request.method == "GET": print("here-->3") 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("signup.html", form=form) else: db.user.insert({ "firsname": form.firstname.data, "lastname": form.lastname.data, "email": form.email.data, "password": form.password.data, }) session['email'] = form.email.data return redirect(url_for('profile')) elif request.method == "GET": return render_template("signup.html", form=form)
def signup(): if 'email' in session: return redirect(url_for('home')) error = None form = SignupForm() if request.method == "POST": if form.validate() == False: return render_template('signup.html', form=form) else: db.create_all() flash('User created. Please, login now!') newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() return redirect(url_for('login')) elif request.method == "GET": return render_template('signup.html', form=form, error=error)
def signup(): """ The branching logic below allows for the segmentation of either a POST or GET method """ if 'email' in session: return redirect(url_for('home')) form = SignupForm() if request.method == "POST": if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email return redirect(url_for('home')) elif request.method == "GET": return render_template('signup.html', form=form)
def signup(): # If user is already signed in, redirect to home page if 'email' in session: return redirect(url_for('home')) form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email return redirect(url_for('home')) elif request.method == 'GET': return render_template("signup.html", form=form)
def signup(): if 'email' in session: return redirect(url_for('home')) form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) #TODO: find a way to hash password during initialization newuser.set_password(form.password.data) newuser.save() session['email'] = newuser.email return redirect(url_for('home')) elif request.method == "GET": return render_template('signup.html', form=form)
def signup(): #Check if session has email in it , if user is logged in redirect to home page directly if 'email' in session: return redirect(url_for('home')) # if user is not logged in and clicked on sign up redirect to sign up page form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email return redirect(url_for('home')) elif request.method == 'GET': return render_template('signup.html', form=form)
def signup(): """A form for users to signup and create an account.""" # Using WTFforms here - see forms.py for breakdown of form code form = SignupForm(request.form) # Checks to see if username is in session. If they've logged in it redirects them to the profile page. if 'username' in session: return redirect(url_for('profile')) # If they haven't logged in, when they fill out the form, send it to this function. This creates a new user in the db. if request.method == 'POST' and form.validate(): new_user = User(username=form.username.data, email=form.email.data, password=form.password.data) db.session.add(new_user) db.session.commit() return redirect(url_for('profile')) # Saves username and email into the session session['email'] = new_user.email session['username'] = new_user.username return redirect(url_for('profile')) return render_template('signup.html', form=form)
def signup(): form = SignupForm() if 'email' in session: return redirect(url_for('dashboard')) 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')) 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('signup.html', form=form)
def signup(): if current_user.is_authenticated: return redirect(url_for('home')) form = SignupForm() if request.method == 'GET': return render_template('signup.html', form=form) if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: firstname = form.firstname.data lastname = form.lastname.data username = form.username.data email = form.email.data password = form.password.data user_from_table = User.query.filter_by(username=username).first() email_from_table = User.query.filter_by(email=email).first() if user_from_table: print("USERNAME ALREADY PRESENT") flash("This username already exists.") return render_template('signup.html', form=form) if email_from_table: print("EMAIL ALREADY PRESENT") flash("This email already exists.") return render_template('signup.html', form=form) newUser = User(firstname, lastname, username, email, password) db.session.add(newUser) db.session.commit() login_user(newUser) flash("Successful signup!") return redirect(url_for('home'))
def signup(): if 'email' in session: return redirect(url_for('home')) form = SignupForm() if request.method == "POST": # If any form fields are empty(means validation check returns false) and return false, the signup page shud be returned back to the user upon hitting Submit if form.validate() == False: return render_template('signup.html', form=form) else: #Create new user instance, and initialize it with data from signup form newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() #Once a new user is signed up for the app, it creates a new session and should then redirect to the homepage session['email'] = newuser.email return redirect(url_for('home')) elif request.method == "GET": return render_template('signup.html', form=form)
def signup(): if 'email' in session: return redirect(url_for('home')) form = SignupForm() #stores the signup form in the var form if request.method == 'POST': if form.validate() == False: return render_template("signup.html", form=form) else: newuser = User(form.first_name.data, form.last_name.data, form.email.data, form.password.data) db.session.add(newuser) db.session.commit() session[ 'email'] = newuser.email #creates a new session when a users signs up for an account return redirect(url_for('home')) elif request.method == 'GET': return render_template( "signup.html", form=form) #this sends the form to a html page called signup.html