Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Merged
merged 3 commits into from
Nov 8, 2020

Conversation

bwgjoseph
Copy link
Contributor

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 and others added 3 commits August 16, 2020 16:50
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
@daffl daffl merged commit 8d25be1 into feathersjs:crow Nov 8, 2020
@daffl
Copy link
Member

daffl commented Nov 8, 2020

That makes sense, thank you!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants