def resend(userKey):
	key = ndb.Key(urlsafe = userKey)
	user = key.get()
	logging.warning(user)
	if user:
		sendConfirmEmail(user)
	return redirect(url_for("home"))
Exemple #2
0
def resend(userKey):
    key = ndb.Key(urlsafe=userKey)
    user = key.get()
    logging.warning(user)
    if user:
        sendConfirmEmail(user)
    return redirect(url_for("home"))
def register():
	form = registerForm()
	if g.user: 
		return redirect(url_for("profile"))
	if form.validate_on_submit():
		user = User(
			email = form.email.data,
			firstName = form.firstName.data,
			lastName = form.lastName.data,
			# password = form.password.data,
			birthday = datetime.strptime(form.birthday_month.data + '%02d'%form.birthday_day.data + form.birthday_year.data, "%b%d%Y").date(),
			username = form.username.data
		)
		#logging.warning(str(user))
		user.put()
		sendConfirmEmail(user)

		session["username"] = user.username

		if not os.environ['SERVER_SOFTWARE'].startswith('Development'):	#if production, cuz mail doesn't work on dev.
			flash("A confirmation link has been sent to your email address.")
			return redirect(url_for("home"))
		else:
			token = URLSafeTimedSerializer(app.config['SECRET_KEY']).dumps(user.key.urlsafe(), salt=app.config['SECURITY_PASSWORD_SALT'])
			confirm_url = url_for("confirmEmail", token = token, _external = True)
			return "<a href={0}>Confirm</a>".format(confirm_url)	#let developer do it manually

	return render_template("register.html", form = form)
Exemple #4
0
def register():
    form = registerForm()
    if g.user:
        return redirect(url_for("profile"))
    if form.validate_on_submit():
        user = User(
            email=form.email.data,
            firstName=form.firstName.data,
            lastName=form.lastName.data,
            # password = form.password.data,
            birthday=datetime.strptime(
                form.birthday_month.data + '%02d' % form.birthday_day.data +
                form.birthday_year.data, "%b%d%Y").date(),
            username=form.username.data)
        #logging.warning(str(user))
        user.put()
        sendConfirmEmail(user)

        session["username"] = user.username

        if not os.environ['SERVER_SOFTWARE'].startswith(
                'Development'):  #if production, cuz mail doesn't work on dev.
            flash("A confirmation link has been sent to your email address.")
            return redirect(url_for("home"))
        else:
            token = URLSafeTimedSerializer(app.config['SECRET_KEY']).dumps(
                user.key.urlsafe(), salt=app.config['SECURITY_PASSWORD_SALT'])
            confirm_url = url_for("confirmEmail", token=token, _external=True)
            return "<a href={0}>Confirm</a>".format(
                confirm_url)  #let developer do it manually

    return render_template("register.html", form=form)