Ejemplo n.º 1
0
def signup():
    try:
        form = SignupForm()
        if form.validate_on_submit():
          print "I am here"
          the_user = session.query(User).filter_by(mobilenumber = form.mobile.data).first()
          if the_user:
            flash("User with same mobile number already exist")
          else:
            user = User(name = form.name.data,
                   email = form.email.data,
                   password = generate_password_hash(form.password.data),
                   mobilenumber = form.mobile.data)
            session.add(user)
            session.commit()
            token = generate_confirmation_token(user.email)
            confirm_url = url_for('confirm_email',token = token,_external = True)
            html = render_template('activate.html',confirm_url = confirm_url)
            subject = "Please confirm your email {}.".format(user.name)
            send_email(user.email,subject,html)
            flash("Thank you for Registering {}.".format(user.name))
            flash("We have sent you a confirmation email to your registered email and its valid for 1 hour")
            flash("It may take 1 minute to arrive")
            flash("Please click on confirmation link sent in mail")
            return redirect(url_for('confirm'))

        return render_template('signup.html',form = form)
    except Exception as e:
        print e
Ejemplo n.º 2
0
def confirm_email(token):
  try:
    email = confirm_token(token)
  except:
    server_error(e)
  user = session.query(User).filter_by(email = email).first()
  if user.confirmed:
    flash("Account already confirmed.Please Login")
    return redirect(url_for('login'))
  else:
    user.confirmed = True
    session.add(user)
    session.commit()
    flash("Superb!!!!  You have confirmed Your account {}.".format(user.name))
    flash("Use GetResume  Website to login and continue")
    return redirect(url_for('emailconfirm'))