def post(self): user = UserRegisterResource.parser.parse_args() if UserModel.find_by_username(user.username): return {'message': 'user already exists'}, 409 user = UserModel(**user) user.add_user() return {'message': 'user added'}, 201
def post(): user = UserRegisterResource.parser.parse_args() if UserModel.find_by_username(user.username): abort(409, message="User Already Exists") new_user = UserModel(**user) new_user.add_user() return {'message': f"added {new_user.username}"}, 201
def post(username): new_user = { 'username': username, 'password': UserRegister.parser.parse_args()['password'] } if does_user_exist(username): return abort( 404, message="user '{}' has already exist".format(username)) new_user = UserModel(**new_user) new_user.add_user() return {'new_user': new_user.json()}, 201
def put(username): user = { 'username': username, 'password': UserRegister.parser.parse_args()['password'] } if does_user_exist(username): changed_user = UserModel.find_by_username(username) changed_user.password = user['password'] db.session.commit() return {'changed_user': changed_user.json()}, 201 new_user = UserModel(**user) new_user.add_user() return {'new_user': new_user.json()}, 201
def create_account(): form = epf() if form.validate_on_submit(): user = UserModel(email=form.email.data, password=form.password.data) user.add_user() send_verification_email(user) # send_email(user.email, subject, html) return 'Email has been sent with instructions to verify your account' return render_template('/accounts/create.html', form=form)