Example #1
0
 def post(self):
     data = UserRegister.parser.parse_args()
     row = UserModel.get_user_by_username(data['username'])
     if row:
         return {"message":"user already exist"},400
     user = UserModel(**data)
     user.save_to_db()
     return {"message":"user created successfully."},201
Example #2
0
def authenticate(username, password):
    user = UserModel.get_user_by_username(username)
    if user and safe_str_cmp(user.password, password):
        return user