Exemplo n.º 1
0
 def post(cls):
     '''post (signup method)'''
     data = request.get_json()
     result = validate.check_for_data(data)
     if result:
         return result, 400
     username = data.get("username")
     name = data.get("name")
     email = data.get("email")
     password = data.get("password")
     confirm_password = data.get("confirm_password")
     message = ""
     if not confirm_password:
         message = "Please Re-enter password"
     if not password:
         message = "Please enter password"
     if not email:
         message = "Please enter email"
     if not username:
         message = "Please enter username"
     if not name:
         message = "Please enter name"
     if message:
         return dict(message=message), 400
     passwords = [password, confirm_password]
     result = validate.validate_register(username, name, email, passwords)
     if "message" in result:
         return result, 400
     my_user = User()
     result = my_user.add_user(name, username, email, password)
     if "error" in result:
         return dict(message=result["message"]), result["error"]
     return result, 201
 def post(cls):
     '''post (signup method)'''
     data = request.get_json()
     result = validate.check_for_data(data)
     if result:
         return result, 400
     username = data.get("username")
     name = data.get("name")
     email = data.get("email")
     password = data.get("password")
     confirm_password = data.get("confirm_password")
     if not username or not name or not email or not password or not confirm_password:
         return dict(
             message="name, username, email, password or confirm_password fields missing"), 400
     passwords = [password, confirm_password]
     result = validate.validate_register(username, name, email, passwords)
     if "message" in result:
         return result, 400
     my_user = User()
     result = my_user.add_user(name, username, email, password)
     if "error" in result:
         return dict(message=result["message"]), result["error"]
     return result, 201