def post(self): data = arguments.parse_args() if UserModel.findByLogin(data['login']): return BadRequest('The informed login already exists.') if UserModel.findByEmail(data['email']): return BadRequest('The informed email already exists.') user = UserModel(**data) user.activated = False user.save() user.send_confirmation_email() return user.json(), 201
def post(self): arguments_copy = arguments arguments_copy.remove_argument('fullname') arguments_copy.remove_argument('email') data = arguments_copy.parse_args() user = UserModel.findByLogin(data['login']) if user and safe_str_cmp(user.password, data['password']): if user.activated: access_token = create_access_token(identity=user.id) return {'access_token': access_token}, 200 return BadRequest('User not confirmed.') return {'message': 'The username or password is incorrect.'}, 401