pallets-eco / flask-security

Quick and simple security for Flask applications
MIT License
635 stars 155 forks source link

can I custom response body from specific endpoint? #985

Closed AppleBoiy closed 4 months ago

AppleBoiy commented 4 months 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 4 months 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