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 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(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(): 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() 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 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(): """ 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 signup(): form = SignupForm(request.form) if request.method == 'POST' and form.validate(): from app.models import User user = User( user_id='1', username=form.first_name.data, email=form.email.data, ) user.set_password(form.password.data) from sqlalchemy.exc import IntegrityError try: db.session.add(user) db.session.commit() flash('You are now a registered user!') return redirect(url_for('main.index')) except IntegrityError: db.session.rollback() flash( 'ERROR! Unable to register {}. Please check your details are correct and try again.' .format(form.name.data), 'error') return render_template('signup.html', form=form)
def register(): """ Shows and processes the signup form """ util.stat_api() form = SignupForm() if flask.request.method == 'POST' and form.validate(): user = users.User(username=form.username.data, password=form.password.data) success, api_response = user.new() if success: flask.flash('Registration successful! Please sign in!') return flask.redirect(flask.url_for('login')) else: flask.flash(api_response) return flask.render_template( 'register.html', api=akdm.config['api'], meta=settings.get_meta_dict(), form=form )
def signup_post(): form = SignupForm(request.form) if form.validate(): username = form.username.data password = form.password.data existing_user = find_user_by_name(username) if existing_user is None: new_user = User(username, password) new_user = insert_user(username, password) if new_user: flash("User '{}' created successfully. Please log in!".format( form.username.data), category='success') else: flash('Error creating user', category='danger') return redirect(url_for('auth.login_get')) else: flash("Username '{}' is already taken".format(form.username.data), category='danger') else: flash_form_errors(form) return render_template('signup.html', title='Sign up', form=form)
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)
def manual_signup(): """ Admin signup page, allows signup outside of registration period """ form = SignupForm(request.form) try: event = Events.query.filter(Events.active).first() if event != None: eventid = event.id timeslots = TimeSlots.query.filter( TimeSlots.event_id == eventid).all() if timeslots != None: [available_slots_choices, available_special_slots_choices ] = get_slots_choices(timeslots) form.availableslots.choices = available_slots_choices form.availablespecialslots.choices = available_special_slots_choices except Exception as e: print(e) return render_template('error.html') if request.method == 'POST' and form.validate(): try: timestamp = datetime.now() name = str(request.form['name']) prename = str(request.form['prename']) gender = Gender(int(request.form['gender'])) email = str(request.form['email']) email2 = str(request.form['email2']) if email != email2: message = 'Deine Mailadressen stimmen nicht überein!\ Bitte geh zurück und korrigiere deine Mailadresse.' return render_template('error.html', message=message) mobile = str(request.form['mobile_nr']) address = str(request.form['address']) birthday = str(request.form['birthday']) studycourse = str(request.form['study_course']) studysemester = str(request.form['study_semester']) perfectdate = str(request.form['perfect_date']) fruit = str(request.form['fruit']) availablespecialslots = None if event.special_slots: availablespecialslots = request.form.getlist( 'availablespecialslots') availableslots = request.form.getlist('availableslots') confirmed = False present = False paid = False slots = 0 if availableslots: slots = int(availableslots[0]) elif availablespecialslots: slots = int(availablespecialslots[0]) else: message = 'Du hast kein passendes Datum ausgewählt!\ Bitte geh zurück und wähle ein dir passendes Datum aus.' return render_template('error.html', message=message) bday = datetime.strptime(birthday, '%d.%m.%Y') chosen_timeslot = TimeSlots.query.filter( TimeSlots.id == int(slots)).first() slot_datetime = str( chosen_timeslot.date.strftime("%A %d. %B %Y")) + ' ' + str( chosen_timeslot.start_time.strftime("%H:%M")) try: new_participant = Participants(creation_timestamp=timestamp, event_id=eventid, name=name, prename=prename, email=email, mobile_nr=mobile, address=address, birthday=bday, gender=gender, study_course=studycourse, study_semester=studysemester, perfect_date=perfectdate, fruit=fruit, slot=slots, confirmed=confirmed, present=present, paid=paid) db.session.add(new_participant) db.session.commit() # The participant signed up successfully # Emit signal and show success page SIGNAL_NEW_SIGNUP.send('signup view', participant=new_participant, slot_datetime=slot_datetime) except Participants.AlreadySignedUpException: message = 'Die E-Mail Adresse ' + email + \ ' wurde bereits für das Speeddating angewendet.\ Bitte versuchen Sie es erneut mit einer neuen E-Mail Adresse.' return render_template('error.html', message=message) except Exception as e: print('Exception of type {} occurred: {}'.format(type(e), str(e))) return render_template('error.html') return render_template('success.html', name=('{} {}'.format(prename, name)), mail=email, datetime=slot_datetime) return render_template('manual_signup.html', form=form, event=event)
def edit_participant(timeslot_id, participant_id): """ Admin edit signed up participants, allows to do changes on an already signed up particpant """ event = Events.query.filter(Events.active).first() slot = TimeSlots.query.get_or_404(timeslot_id) participant = Participants.query.get_or_404(participant_id) form = SignupForm(request.form, obj=participant) if event != None: eventid = event.id timeslots = TimeSlots.query.filter(TimeSlots.event_id == eventid).all() if timeslots != None: [available_slots_choices, available_special_slots_choices] = get_slots_choices(timeslots) form.availableslots.choices = available_slots_choices form.availablespecialslots.choices = available_special_slots_choices form.birthday.data = participant.birthday.strftime("%d.%m.%Y") form.email2.data = participant.email if len(available_slots_choices) > 0: for i in range(0, len(available_slots_choices)): if participant.slot in available_slots_choices[i]: form.availableslots.data = [participant.slot] if len(available_special_slots_choices) > 0: for i in range(0, len(available_special_slots_choices)): if participant.slot in available_special_slots_choices[i]: form.availablespecialslots.data = [participant.slot] if request.method == 'POST' and form.validate(): try: form.populate_obj(participant) email = str(request.form['email']) email2 = str(request.form['email2']) if email != email2: message = 'Deine Mailadressen stimmen nicht überein!\ Bitte geh zurück und korrigiere die Mailadresse.' return render_template('error.html', message=message) gender = Gender(int(request.form['gender'])) birthday = str(request.form['birthday']) participant.birthday = datetime.strptime(birthday, '%d.%m.%Y') participant.gender = gender availablespecialslots = None if event.special_slots: availablespecialslots = request.form.getlist( 'availablespecialslots') availableslots = request.form.getlist('availableslots') slots = 0 if availableslots: slots = int(availableslots[0]) elif availablespecialslots: slots = int(availablespecialslots[0]) else: message = 'Du hast kein passendes Datum ausgewählt!\ Bitte geh zurück und wähle ein dir passendes Datum aus.' return render_template('error.html', message=message) participant.slot = int(slots) db.session.commit() except Exception as e: print('Exception of type {} occurred: {}'.format(type(e), str(e))) return render_template('error.html') return redirect(request.referrer) return render_template('edit_participant.html', form=form, event=event, slot=slot, participant=participant)
def signup(): form = SignupForm(request.form) if request.method == 'POST' and form.validate(): flash('Signup requested for {}'.format(form.name.data)) return redirect(url_for("templates.homepage")) return render_template('signup.html', form=form)