def register(): """ 验证参数的合法性,提交表单信息 :return: # user.nickname = form.nickname.data # user.email = form.email.data # user.passwd = form.password.data """ if request.method == 'POST': form = RegisterForm(request.form) # logger.info(form) if form.validate(): with db.auto_commit(): user = User() user.set_attrs(form.data) # 这样是不好.. # user.password = generate_password_hash(form.password.data) db.session.add(user) return redirect(url_for('web.login')) else: logger.info(form.errors) return render_template('auth/register.html', form=form) elif request.method == 'GET': pass return render_template('auth/register.html', form={'data': {}})
def user_register(): form = RegisterForm(request.form) if request.method == 'POST' and form.validate(): user = User() user.set_attrs(form.data) user.updatetime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime( (time.time()))) # 修改数据更新时间 # 判断是否已经存在该公司,如不存在,则创建该公司的公司管理员账户,并创建相应数据表 # 如果存在,则只能创建公司普通人员账户,不创建数据表 if user.authority == 'com_person': db.session.add(user) db.session.commit() else: # 公司不存在,且注册时选择了公司管理员,则允许创建用户,并创建相关数据表 company = Company() company.set_attrs(form.data) company.company_number = "%03d" % (Company.query.count() + 1) db.session.add(company) db.session.add(user) db.session.commit() # 创建报告保存文件夹,根据公司编号创建,如超级管理员为001,则文件夹名为001 os.makedirs( os.path.join(current_app.config['DOCXFILE_DIR'], company.company_number)) return render_template('user/userRegister.html', messages={'message': ['注册成功!']}) else: return render_template('user/userRegister.html', messages=form.errors)
def register(): logger.info("Entered register method") directoryPath = os.path.dirname(os.path.realpath(__file__)) with open("%s/../endpoints.yaml" % directoryPath, 'r') as stream: registerUrl = yaml.load(stream)['registerUrl'] form = RegisterForm(request.form) if request.method == 'POST' and form.validate(): email = form.email.data username = form.username.data password = sha256_crypt.encrypt(str(form.password.data)) data = { "email": form.email.data, "username": form.username.data, "password": sha256_crypt.encrypt(str(form.password.data)) } data = json.dumps(data) logger.info("Received form data") logger.info("Generating token") token = jwt.encode({}, app.config['SECRET_KEY']) token = token.decode('UTF-8') headers = {'access-token': token, 'content-type': 'application/json'} url = registerUrl response = requests.post(url, data=data, headers=headers) logger.info("Response from Register: {}".format(response.status_code)) if response.status_code is 200: flash('You are now registered and can login', 'success') return redirect(url_for('index')) return render_template('register.html', form=form)
def register(): form = RegisterForm(request.form) if request.method == 'POST' and form.validate(): user = User() user.set_attr(form.data) db.session.add(user) db.commit() redirect(url_for(endpoint='web.login')) pass
def register(): form = RegisterForm() if form.validate_on_submit(): novo_usuario = User(form.name.data, form.email.data, form.password.data) db.session.add(novo_usuario) db.session.commit() flash('Agora você pode logar no sistema.') return redirect(url_for('login')) return render_template('usuario/register.html', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('index')) form = RegisterForm() if form.validate_on_submit(): user = Profesor(nombre=form.nombre.data, email=form.email.data, curso=form.curso.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash('Exito !, se registro como profesor') return redirect(url_for('login')) return render_template('views/register.html', title='Registro', form=form)
def register(): form = RegisterForm() if request.method == 'POST': username = request.form['username'] password = request.form['password'] db = get_db() error = None return render_template('auth/register.html', form=form)
def register(): form = RegisterForm(request.form) if request.method == 'POST' and form.validate(): email = form.email.data username = form.username.data password = sha256_crypt.encrypt(str(form.password.data)) # Create cursor cur = mysql.connection.cursor() cur.execute( "INSERT INTO user(username, password, email, type) VALUES (%s, %s, %s, %s)", (username, password, email, "customer")) # Commit to DB mysql.connection.commit() # Close connection cur.close() flash('You are now registered and can login', 'success') return redirect(url_for('index')) return render_template('register.html', form=form)