def post(self): form = SignupForm(request.form) print("form validate", form.validate()) print("form errors", form.errors) if form.validate() == False: print("form errors", form.errors) return render_template("signup.html", form=form) else: # import pdb;pdb.set_trace(); user = User( username=form.username.data, password=form.password.data, firstname=form.firstname.data, lastname=form.lastname.data, email=form.email.data, ) db.session.add(user) db.session.commit() msg = Message( "Hello" + " " + form.firstname.data + " " + form.lastname.data, sender="*****@*****.**", recipients=[form.email.data], ) msg.body = "Thanks for signup , we will get in touch with you soon!!!" mail.send(msg) user = User.query.all() print("users are :: ", user) print("@@@@@@@@@@@ redirected to showSignIn part") return redirect(url_for("index"))
def signup(): form = SignupForm(request.form) if form.validate_on_submit(): user = User() form.populate_obj(user) username_exist = User.query.filter_by(username=form.username.data).first() email_exist = User.query.filter_by(email=form.email.data).first() if username_exist: form.username.errors.append('User already exists') if email_exist: form.email.errors.append('Email already exists') if username_exist or email_exist: return render_template('signup.html', form=form, signinpage_form=LoginForm(), page_title='Sign up form') else: user.firstname = 'firstname', user.lastname = 'lastname', user.email = form.email.data, user.password = hash_password(form.password.data), user.biography = 'This is a test portfolio', user.avatar = 'http://placehold.it/350/300', db.session.add(user) db.session.commit() return render_template("signup-success.html", signinpage_form=LoginForm(), form=form, page_title='Success page on signup', user=user) else: return render_template('signup.html', signinpage_form=LoginForm(), form=form, page_title='This is the signup form')
def post(self): form = SignupForm(request.form) print("form validate", form.validate()) print("form errors", form.errors) if form.validate() == False: print("form errors", form.errors) return render_template('signup.html', form=form) else: #import pdb;pdb.set_trace(); user = User(username=form.username.data, password=form.password.data, firstname=form.firstname.data, lastname=form.lastname.data, email=form.email.data) db.session.add(user) db.session.commit() msg = Message('Hello' + ' ' + form.firstname.data + ' ' + form.lastname.data, sender='*****@*****.**', recipients=[form.email.data]) msg.body = 'Thanks for signup , we will get in touch with you soon!!!' mail.send(msg) user = User.query.all() print("users are :: ", user) print("@@@@@@@@@@@ redirected to showSignIn part") return redirect(url_for('index'))
def signup(): form = SignupForm() if form.validate_on_submit(): hashed_password = generate_password_hash(form.password.data, method='sha256') new_owner = crud.create_owner(form.email.data, form.first_name.data, form.last_name.data, hashed_password) session['owner_email'] = new_owner.email return redirect('/pupsignup') return render_template("signup.html", form=form)
def signup(): form = SignupForm() if form.validate_on_submit(): user = Users(first_name=form.first_name.data, last_name=form.last_name.data, email=form.email.data, password=form.password.data, is_active=True) db.session.add(user) db.session.commit() return redirect(url_for('root.home')) return render_template("account/signup.html", form=form)
def singup(): 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.first_name.data, form.last_name.data, form.email.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(): # Read in the WTForm form = SignupForm() # If the form has already been presented to the user, and it has valid # data, then save the form data (just pickle it) and go to the home page. if form.validate_on_submit(): with open('formdata', 'w') as formfile: pickle.dump(form, formfile) return redirect(url_for('home')) flash_errors(form) # Well, either the form had incorrect data, or we need to make an # initial presentation of the form to the user return render_template('signup.html', form=form)
def login(): loginForm = SignupForm() if request.method == 'GET': return render_template('login.html', form=loginForm) elif request.method == 'POST': if loginForm.validate_on_submit(): user=session.query(UserAccount).filter_by(email=loginForm.email.data).first() if user is not None: if user.decode_password(loginForm.password.data): login_user(user) return "User logged in" else: return "Wrong password" else: return "user doesn't exist" else: return "form not validated"
def signup(): form = SignupForm() try: if form.validate_on_submit(): user_name = request.form.get('username', None) password = request.form.get('password', None) email = request.form.get('email', None) if not checkusername(user_name): return render_template('error.html', title='Signup Fail', value='Illegal username') if not checkemail(email): return render_template('error.html', title='Signup Fail', value='Wrong email format') user = User(user_name) user.email = email if not user.exists(): token = user.generate_confirmation_token() user.password = password sendemail(user.email, 'confirm Your Account', 'confirm', user=user, token=token) return redirect(url_for('index')) #if ret: #return redirect(url_for('index')) #else: #return render_template('error.html',title='Signup Fail', value='Fail to send email') else: return render_template('error.html', title='Signup Fail', value='User or email exists') else: return render_template('error.html', title='Signup Fail', value='Please fill all part') except: return render_template( 'error.html', title='Signup Fail', value= 'Oops, we encounter some problems, please contact us for details.')
def signup(): error = None form = SignupForm(request.form) if request.method == 'POST': if form.validate_on_submit(): user = NGO.query.filter_by(name=request.form['username']).first() if (user is not None): error = 'Already Registered' else: session['logged_in'] = True db.session.add( NGO(request.form['username'], request.form['description'], request.form['password'])) db.session.commit() flash('You were logged in.') return redirect(url_for('home.home')) return render_template('signup.html', form=form, error=error)
def signup(): form = SignupForm() if form.validate_on_submit(): user = User( id=str(uuid.uuid5(uuid.uuid4(), str(form.email.data))), username=form.username.data, email=form.email.data, passwd=form.passwd.data ) config = Config( id=str(uuid.uuid5(uuid.uuid4(), str(user.id))), uid=user.id, theme='darkly', ) db.session.add(user) db.session.add(config) db.session.commit() flash("注册成功", 'success') return redirect(url_for('signin')) return render_template('signup.html', form=form, signup_active="active")
def signup(): '''index''' form = SignupForm() if request.method == "POST": if form.validate_on_submit(): if (form.passworda.data == form.passwordb.data): passhash = generate_password_hash(form.passworda.data) email = form.email.data hostel = form.hostel.data rollno = form.rollno.data firstname = form.firstname.data lastname = form.lastname.data rows = db.execute( "SELECT 'email' from TEST4 where email=:email", email=email) if rows == []: db.execute("INSERT INTO TEST4('email','passhash','hostel','rollno','firstname','lastname') \ values (:email, :passw, :hostel, :rollno, :firstname, :lastname)" , \ email=email, \ passw=passhash, hostel=hostel, rollno=rollno, firstname= firstname, lastname=lastname) form.email.data = '' form.passworda.data = '' form.passwordb.data = '' form.hostel.data = '' form.rollno.data = '' form.firstname.data = '' form.lastname.data = '' id = db.execute( "SELECT id,firstname from test4 where email = :email", email=email) send_conf(email, id[0]['id'], id[0]['firstname']) flash("Confirmation sent. Expires in 1 hour") return render_template('index.html') else: flash("E-Mail already has exisiting account!") return redirect(url_for('signup')) else: return redirect(url_for('signup')) if request.method == "GET": return render_template("signup.html", form=form)
def signup(): form = SignupForm(request.form) def showMessage(type): if type == 'success': flash( 'Your account has been created. <a class="black-text" href="{0}">write</a> a new note?' .format(url_for('note.write')), 'success') if type == 'exists': flash('This Email address is exists.', 'warning') if type == 'error': flash('Something error when save.', 'error') if request.method == 'POST' and form.validate(): user = User(form.email.data, form.password.data, form.nick_name.data) result = user.create() showMessage(result) login_user(user, remember=True) return render_template('signup.html', title='signup', form=form)
def signup(): if not flask_login.current_user.is_authenticated: form = SignupForm() if form.validate_on_submit(): user = (db.session.query(User).filter( User.user_nick.ilike(form.nickname.data)).first()) if not user: new_user = User(form.nickname.data, form.mail.data, form.password.data, form.nickname.data) db.session.add(new_user) db.session.commit() return flask.redirect(flask.url_for("login")) return flask.render_template("signup.html", title="Frigo | Inscription", form=form) return flask.redirect(flask.url_for("index"))
def signup(): form = SignupForm() if form.validate_on_submit(): exist_username = User.query.filter( User.username == form.username.data).first() exist_email = User.query.filter(User.email == form.email.data).first() if exist_username: flash(error_msgs['duplicate_user'], 'auth_error') elif exist_email: flash(error_msgs['duplicate_email'], 'auth_error') else: hashed_pw = generate_password_hash(form.password.data, method='sha256') new_user = User(username=form.username.data, email=form.email.data, password=hashed_pw) db.session.add(new_user) db.session.commit() createTutorial(new_user.id) return redirect(url_for('auth.login')) return render_template('signup.html', form=form)
def signup(request): if request.method == 'POST': form = SignupForm(data=request.POST) #print request.POST if form.is_valid(): new_user = form.save() subject = 'User Registration' message = 'Thank you for registering. \nYour username is: %s\nYour Password is %s' % ( form.data['username'], form.data['password']) from_email = '*****@*****.**' to_email = [form.data['email']] send_mail(subject, message, from_email, to_email, fail_silently=False) return HttpResponseRedirect("/accounts/profile/") else: print 'Form Not Valid' #print(form.data['last_name']) #print(dir(form)) else: form = SignupForm() print 'BAD ATTEMPT, MUST BE POST' return render_to_response('signup.html', {'form': form})
def signup(): form = SignupForm(request.form) def showMessage(type): if type == 'success': flash('Your account has been created. <a class="black-text" href="{0}">write</a> a new note?'.format(url_for('note.write')), 'success') if type == 'exists': flash('This Email address is exists.', 'warning') if type == 'error': flash('Something error when save.', 'error') if request.method == 'POST' and form.validate(): user = User( form.email.data, form.password.data, form.nick_name.data) result = user.create() showMessage(result) login_user(user, remember=True) return render_template('signup.html', title='signup', form=form)
def signup(request): if request.method == 'POST': form = SignupForm(data=request.POST) #print request.POST if form.is_valid(): new_user = form.save() subject = 'User Registration' message = 'Thank you for registering. \nYour username is: %s\nYour Password is %s' %(form.data['username'],form.data['password']) from_email = '*****@*****.**' to_email = [form.data['email']] send_mail(subject, message, from_email, to_email, fail_silently=False) return HttpResponseRedirect("/accounts/profile/") else: print'Form Not Valid' #print(form.data['last_name']) #print(dir(form)) else: form = SignupForm() print 'BAD ATTEMPT, MUST BE POST' return render_to_response('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, form.account.data) db.session.add(newuser) db.session.commit() session['email'] = newuser.email session['uid'] = newuser.uid pin = Account_Pin(newuser.uid, dpo.randomNum()) db.session.add(pin) db.session.commit() return render_template('welcome.html', fname=newuser.firstname, lname=newuser.lastname, actnumber=newuser.uid, actpin=pin.pin) 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(): form = SignupForm() if form.validate_on_submit(): new_user = User(full_name=form.full_name.data, email=form.email.data, password=form.password.data) db.session.add(new_user) try: db.session.commit() except Exception as e: print(e) db.session.rollback() return render_template( "signup.html", form=form, message= "This Email already exists in the system! Please Log in instead." ) finally: db.session.close() return render_template("signup.html", message="Successfully Signed Up!") return render_template("signup.html", form=form)
def register(): signupForm = SignupForm() if request.method == 'GET': return render_template('register.html', form = signupForm) elif request.method == 'POST': if signupForm.validate_on_submit(): if session.query(UserAccount).filter_by(email=signupForm.email.data).first() is not None: return "Email address already exists" else: def encode_password(password): return pbkdf2_sha512.hash(password) newuser = UserAccount( email=signupForm.email.data, password=encode_password(signupForm.password.data) ) session.add(newuser) session.commit() login_user(newuser) return "User created!!!" else: return "Form didn't validate"
def signup(): form = SignupForm(request.form) if form.validate_on_submit(): user = User() form.populate_obj(user) username_exist = User.query.filter_by( username=form.username.data).first() email_exist = User.query.filter_by(email=form.email.data).first() if username_exist: form.username.errors.append('User already exists') if email_exist: form.email.errors.append('Email already exists') if username_exist or email_exist: return render_template('signup.html', form=form, signinpage_form=LoginForm(), page_title='Sign up form') else: user.firstname = 'firstname', user.lastname = 'lastname', user.email = form.email.data, user.password = hash_password(form.password.data), user.biography = 'This is a test portfolio', user.avatar = 'http://placehold.it/350/300', db.session.add(user) db.session.commit() return render_template("signup-success.html", signinpage_form=LoginForm(), form=form, page_title='Success page on signup', user=user) else: return render_template('signup.html', signinpage_form=LoginForm(), form=form, page_title='This is the signup form')
def signup(): form = SignupForm() return render_template("signup.html", form=form)
def home(): signup_form = SignupForm() if request.form: if signup_form.validate_on_submit(): verification_token = create_random_string() salt = create_random_string() email_address = request.form.get("email_address") if "+" in email_address: return render_template("index.html", signup_form=signup_form, is_plus_sign_in_email=True, sending_error=False, is_captcha_valid=True, is_email_address_invalid=True) regex = "^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$" if not re.search(regex, email_address): return render_template( "index.html", signup_form=signup_form, is_plus_sign_in_email=False, is_email_address_invalid=False, sending_error=False, is_captcha_valid=True, ) result = list( db.engine.execute( "SELECT '' FROM customers WHERE encode(digest(email_address_salt || ' %s', 'sha1'), 'hex') = email_address_hash" % (email_address))) if len( list(result) ) > 0: # don't send verification and don't notify attacker that this email belongs to a customer return render_template("index.html", signup_form=signup_form, sending_error=False, sent_verification=True, is_captcha_valid=True, is_email_address_invalid=True) hash_object = hashlib.sha1() hash_object.update(str(salt).encode('utf-8')) hash_object.update(str(' ' + email_address).encode('utf-8')) email_hash = hash_object.hexdigest() customer = Customer(salt, email_hash, verification_token) db.session.add(customer) db.session.commit() sending_response = send_verification_email(email_address, verification_token) if sending_response == "Forbidden": return render_template("index.html", signup_form=signup_form, sending_error=True, is_captcha_valid=True, is_email_address_invalid=True) return render_template( "index.html", signup_form=signup_form, sending_error=False, sent_verification=True, is_captcha_valid=True, is_email_address_invalid=True ) # regardless if already verified we claim success because we don't disclose to attackers email addresses else: return render_template("index.html", signup_form=signup_form, is_captcha_valid=False, is_email_address_invalid=True) return render_template("index.html", signup_form=signup_form, is_captcha_valid=True, is_email_address_invalid=True)