Sitelet https://web.archive.org/web/20201028100919/https://github.com/feathersjs/feathers/pull/2042
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: consistent response return between local and jwt strategy #2042

Open
wants to merge 2 commits into
base: crow
from

Conversation

@bwgjoseph
Copy link
Contributor

@bwgjoseph bwgjoseph commented Aug 16, 2020

Currently, when /authentication service is trigger with local strategy, it is missing authentication.accessToken and authentication.payload field as compared to jwt strategy

This commit attempts to ensure consistency in both response

// response from 'jwt' strategy
{
    "accessToken": "<token>",
    "authentication": {
        "strategy": "local",
        "accessToken": "<token>",
        "payload": {
            "iat": 1597565489,
            "exp": 1597651889,
            "aud": "https://yourdomain.com",
            "iss": "feathers",
            "sub": "5edb8a3f8a2e8936c429d5ba",
            "jti": "e64f9caa-e738-47da-9c27-fe8c026ab627"
        }
    },
    "user": {
        "_id": "123456",
        "email": "helloworld@gmail.com",
        "createdAt": "2020-06-06T12:21:19.167Z",
        "updatedAt": "2020-06-06T12:24:55.164Z",
        "__v": 0
    }
}

// response from 'local' strategy (before)
{
    "accessToken": "<token>",
    "authentication": {
        "strategy": "local"
    },
    "user": {
        "_id": "123456",
        "email": "helloworld@gmail.com",
        "createdAt": "2020-06-06T12:21:19.167Z",
        "updatedAt": "2020-06-06T12:24:55.164Z",
        "__v": 0
    }
}

// response from 'local' strategy (after)
{
    "accessToken": "<token>",
    "authentication": {
        "strategy": "local"
        "accessToken": "<token>",
        "payload": {
            "iat": 1597565489,
            "exp": 1597651889,
            "aud": "https://yourdomain.com",
            "iss": "feathers",
            "sub": "5edb8a3f8a2e8936c429d5ba",
            "jti": "e64f9caa-e738-47da-9c27-fe8c026ab627"
        }
    },
    "user": {
        "_id": "123456",
        "email": "helloworld@gmail.com",
        "createdAt": "2020-06-06T12:21:19.167Z",
        "updatedAt": "2020-06-06T12:24:55.164Z",
        "__v": 0
    }
}

I added in authentication package instead of authentication-local because jsonwebtoken is already available and it seem like the correct place to add

bwgjoseph added 2 commits Aug 16, 2020
Currently, when /authentication service is trigger with 'local' strategy, it is missing `authentication.accessToken` and `authentication.payload` field as compared to 'jwt' strategy
This commit attempts to ensure consistency in both response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.