コード例 #1
0
ファイル: views.py プロジェクト: nguyenph88/Old-Books-Trading
def register():
  # If user is already login then redirect user to the profile page
  if g.user is not None and g.user.is_authenticated():
    return redirect(url_for('users.home'))
  # Otherwise bring up the register form  
  form = RegisterForm(request.form)
  if form.validate_on_submit():
    # create an user instance not yet stored in the database
    user = User(nickname=form.nickname.data, fullname=form.fullname.data, email=form.email.data,\
      password=generate_password_hash(form.password.data), badges=categorizeEmail(form.email.data))
    # Insert the record in our database and commit it
    user.status =0
    try:
      db.session.add(user)
      db.session.commit()
    except:
      db.session.rollback()
      flash('Email hoac nickname bi trung')
      return render_template("users/register.html", form=form)

    # Log the user in, as he now has an id and name---> allow login when verify already, so not set the session
    #session['user_id'] = user.id
    #session['username'] = user.nickname
    #send email to verify
    
    follower_notification(form, 'follower_email.html')
    # flash will display a message to the user
    # flash('Thanks for registering')
    # redirect user to the 'home' method of the user module.
    flash('chuyentay.com has been send email co your email adress, please visit to verify your account')
    return redirect(url_for('users.home'))
  return render_template("users/register.html", form=form)
コード例 #2
0
ファイル: views.py プロジェクト: nguyenph88/Old-Books-Trading
def adduser():
  nickname = 'cb5'
  fullname = 'Tran Van Huan'
  email = '*****@*****.**'
  password = '******'
  badges = categorizeEmail(email)

  user = User(nickname=nickname, fullname=fullname, email=email,\
      password=generate_password_hash(password), badges=badges)
  db.session.add(user)
  db.session.commit()
  flash('created ' + nickname)
  return render_template("/bimatquansu/blank.html")