Flask-Middleware / flask-security

Quick and simple security for Flask applications
MIT License
622 stars 154 forks source link

can I custom response body from specific endpoint? #985

Closed AppleBoiy closed 1 month ago

AppleBoiy commented 1 month ago

Can I custom the default response for a specific endpoint?

normally when login success the response will be like this:

{
    "meta": {
        "code": 200
    },
    "response": {
        "csrf_token": "token",
    }
}

so, after login process success, I want to add some user data to the response, like this:

{
    "meta": {
        "code": 200
    },
    "response": {
        "csrf_token": "token",
        "user": {
            "id": 1,
            "name": "John Doe",
            "email": "example@mail.com"
        }
    }
}
jwag956 commented 1 month ago

Check out https://flask-security-too.readthedocs.io/en/stable/models.html#custom-user-payload

Also - in the future - please ask questions over in Discussions (on github). Thanks