def init_data(): """ init data """ from domain.model.user import User sha1 = hashlib.sha1() sha1.update('123456') user = User("*****@*****.**") user.nickname = 'fainle' user.password = sha1.hexdigest() db_session.add(user) db_session.commit()
def register(): register_form = RegisterForm(request.form) if request.method == 'POST': if register_form.validate(): user = User(register_form.email.data) user.nickname = register_form.nickname.data sha1 = hashlib.sha1() sha1.update(register_form.password.data) user.password = sha1.hexdigest() db_session.add(user) db_session.commit() session['user_id'] = user.id session['nickname'] = user.nickname return redirect(request.args.get('next') or '/user') return render_template('/user/register.html', registerform=register_form)
def init_data(): """ init data """ from domain.model.user import User sha1 = hashlib.sha1() sha1.update('123456') user = User("*****@*****.**") user.nickname = 'fainle' user.password = sha1.hexdigest() db_session.add(user) db_session.commit()
def register(): register_form = RegisterForm(request.form) if request.method == 'POST': if register_form.validate(): user = User(register_form.email.data) user.nickname = register_form.nickname.data sha1 = hashlib.sha1() sha1.update(register_form.password.data) user.password = sha1.hexdigest() db_session.add(user) db_session.commit() session['user_id'] = user.id session['nickname'] = user.nickname return redirect(request.args.get('next') or '/user') return render_template('/user/register.html', registerform=register_form )