def register(): if request.method == 'POST': e_mail = request.form['email'] name = request.form['username'] passwrd = generate_password_hash(request.form['password']) if bool(re.search(r'@', e_mail)) is False: flash("Email must have an @ symbol") return render_template('register.html') if len(request.form['password']) > 12 or len( request.form['password']) < 6: flash("Password length must be between 12 and 6 chars") return render_template('register.html') User.create(username=name, password=passwrd, email=e_mail) flash("New User added successfully!") return render_template('register.html')
def post(self): args = parser.parse(UserAPI.WEBARGS, request) try: user = User.create(args["username"], args["email"]) return make_response(jsonify(user.to_dict()), 200) except exc.IntegrityError as e: errorInfo = e.orig.args error_message = errorInfo[0] raise exceptions.APIException( message='Unable to create user, duplicates found: {}'.format( error_message))