def delete(self):
        parse = reqparse.RequestParser()
        parse.add_argument('username',
                           type=str,
                           required=True,
                           help="Username is required")
        data = parse.parse_args()
        user = AuthModel.find_by_username(data['username'])
        print("USER = "******"message": "User DELETED Successfully"}, 200

        return {"message": "No data"}, 400
    def post(self):
        data = UserRegistration.parse.parse_args()
        user = AuthModel.find_by_username(data['username'])
        if user:
            return {
                "AlreadyExistError": {
                    "error": "Username already exist"
                }
            }, 400

        user = AuthModel(**data)
        user.save_to_db()

        return {
            "message": "User Created Successfully",
            "User": user.json()
        }, 201
    def post(self):
        data = UserLogin.parse.parse_args()
        user = AuthModel.find_by_username(data['username'])

        if user and safe_str_cmp(user.password, data['password']):
            expires = timedelta(days=5)
            access_token = create_access_token(identity=user.id,
                                               expires_delta=expires,
                                               fresh=True)
            if user.role == "Customer":
                return {
                    "username": user.username,
                    "phone": user.phone,
                    "city": user.city,
                    "role": user.role,
                    "access_token": access_token,
                }, 200
            else:
                return {
                    "role": user.role,
                    "id": user.id,
                    "access_token": access_token,
                }, 200
        return {"error": "Username or Password may incorrect"}, 400