Beispiel #1
0
def register():
    register_form = forms.SignupForm(request.form)
    current_app.logger.info(request.form)
    if request.method == 'POST' and not register_form.validate():
        current_app.logger.info(register_form.errors)
        return '注册失败!'
    elif request.method == 'POST' and register_form.validate():
        email = request.form['email']
        password_hash = flask_bcrypt.generate_password_hash(
            request.form['password'],
        )
        # Prepare User with register info from form
        user = User(email, password_hash)

        try:
            user.save()
            if login_user(user, remember='no'):
                flash('登录成功!')
                return redirect('/game')
            else:
                flash('登录失败!')
        except:
            flash('无法注册此电子邮箱地址!')
            current_app.logger.error(
                'Error on Registration - possible duplicate emails.'
            )

    # Prepare registration form
    template_data = {'form': register_form}
    return render_template('/auth/register.html', **template_data)
Beispiel #2
0
def register():
    
    form = RegisterForm(request.form)
    current_app.logger.info(request.form)

    if request.method == "POST" and form.validate() == False:
        current_app.logger.info(form.errors)
        return "Registration Error"

    elif request.method == "POST" and form.validate():
        email = request.form['email']
        username = request.form['username']

        # generate password hash
        password_hash = flask_bcrypt.generate_password_hash(request.form['password'])
        
        user = User(email, password_hash, True, username)

        try:
            user.save()
            if login_user(user, remember="no"):
                flash("Logged in!")
                return redirect(request.args.get('next') or '/jobs')
            else:
                flash("Unable to log you in")
        except:
            flash("Unable to register with that email address")
            current_app.logger.error("Error on registration - possible duplicate emails")

    return render_template('forms/register.html', form = form)
Beispiel #3
0
def register():
    form = registerForm();
    if form.validate_on_submit():
        
        name = request.form.get('name')
        email = request.form.get('email').lower()
        password = request.form.get('color')
        
        user = User(email, password, name)
        
        # send email to confirm email
        subject = "Confirm your email for //hackRamapo"

        token = ts.dumps(email, salt='email-confirm-key')

        confirm_url = url_for(
            'confirm_email',
            token=token,
            _external=True)

        html = render_template('email/activate.html',
                              confirm_url=confirm_url)

        emails = []
        emails.append(email)
        
        msg = Message(subject, sender=ADMINS[0], recipients=emails)
        msg.html = html
        
        try:
            user.save()
            if login_user(user, remember=False):
                with app.app_context():
                    mail.send(msg)
                return redirect('/profile')
            else:
                flash("unable to log in")
        except:
            print("Registration Failed")
            
    return render_template('register.html', form=form, colors=colors);
Beispiel #4
0
def register():
	
	registerForm = forms.SignupForm(request.form)
	current_app.logger.info(request.form)

	if request.method == 'POST' and registerForm.validate() == False:
		current_app.logger.info(registerForm.errors)
		return "uhoh registration error"

	elif request.method == 'POST' and registerForm.validate():
		email = request.form['email']
		first_name = request.form['first_name']
		last_name = request.form['last_name']
		
		# generate password hash
		password_hash = flask_bcrypt.generate_password_hash(request.form['password'])

		# prepare User
		user = User(email,password_hash,first_name,last_name)
		print user

		try:
			user.save()
			if login_user(user, remember="no"):
				flash("Logged in!")
				return redirect('/')
			else:
				flash("unable to log you in")

		except:
			flash("unable to register with that email address")
			current_app.logger.error("Error on registration - possible duplicate emails")

	# prepare registration form			
	# registerForm = RegisterForm(csrf_enabled=True)
	templateData = {

		'form' : registerForm
	}

	return render_template("/auth/register.html", **templateData)
Beispiel #5
0
def register():
	
	registerForm = forms.SignupForm(request.form)
	current_app.logger.info(request.form)

	if request.method == 'POST' and registerForm.validate() == False:
		current_app.logger.info(registerForm.errors)
		return "uhoh registration error"

	elif request.method == 'POST' and registerForm.validate():
		email = request.form['email']
		if email.find("creighton.edu") == -1: #checks to see if creighton email
			return "Must be a creigthon email!"
		# generate password hash
		password_hash = flask_bcrypt.generate_password_hash(request.form['password'])

		# prepare User
		user = User(email,password_hash)
		print user

		try:
			user.save()
			# user.search_form = SearchForm()
			if login_user(user, remember="yes"):
				flash("Logged in!")
				return redirect('/home')
			else:
				flash("unable to log you in")

		except:
			flash("unable to register with that email address")
			current_app.logger.error("Error on registration - possible duplicate emails")

	# prepare registration form			
	# registerForm = RegisterForm(csrf_enabled=True)
	templateData = {
		'form' : registerForm
	}

	return render_template("/auth/register.html", **templateData)
def register():
    registerForm = forms.SignupForm(request.form)
    current_app.logger.info(request.form)

    if request.method == 'POST' and registerForm.validate() == False:
        current_app.logger.info(registerForm.errors)
        return "uhoh registration error"

    elif request.method == 'POST' and registerForm.validate():
        email = request.form['email']

        # generate password hash
        password_hash = flask_bcrypt.generate_password_hash(
            request.form['password'])

        # prepare User
        user = User(email, password_hash)
        print(user)

        try:
            user.save()
            if login_user(user, remember="no"):
                # flash("Logged in!")
                return redirect('/')
            else:
                pass
                # flash("unable to log you in")

        except:
            # flash("unable to register with that email address")
            current_app.logger.error(
                "Error on registration - possible duplicate emails")

    # prepare registration form
    # registerForm = RegisterForm(csrf_enabled=True)
    templateData = {'form': registerForm}

    return render_template("/auth/register.html", **templateData)