def post(self): parser = reqparse.RequestParser() parser.add_argument('facebookID', type=str, help='Facebook ID', location='form') parser.add_argument('email', type=str, help='User email', location='form', required=True) parser.add_argument('firstName', type=str, help='First Name', location='form', required=True) parser.add_argument('lastName', type=str, help='Last Name', location='form', required=True) parser.add_argument('password', type=str, help='Password', location='form', required=True) args = parser.parse_args() person_model = PersonModel() person_model.email = args['email'] items = PersonModel.query.filter_by(email=person_model.email).all() if len(items) > 0: return Constants.error_with_message_and_status('user_is_already_exist', 401) parameter = 'password' if not parameter in args: return Constants.error_missed_parameter(parameter) person_model.first_name = args['firstName'] person_model.last_name = args['lastName'] person_model.facebook_id = args['facebookID'] # Encrypt user password password = request.form['password'] encr_password = passlib.encrypt(password, salt_length=100) person_model.password = encr_password # Generate user token with expiration date person_model.token = TokenSerializer.generate_auth_token(person_model.person_id) # Add person to the model db.session.add(person_model) db.session.commit() return person_model.to_dict()