feat: consistent response return between local and jwt strategy by bwgjoseph · Pull Request #2042 · feathersjs/feathers · GitHub
Skip to content

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

Merged
daffl merged 3 commits into
feathersjs:crowfrom
bwgjoseph:pr/sync-auth-response
Nov 8, 2020
Merged

feat: consistent response return between local and jwt strategy#2042
daffl merged 3 commits into
feathersjs:crowfrom
bwgjoseph:pr/sync-auth-response

Conversation

@bwgjoseph

Copy link
Copy Markdown
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

daffl commented Nov 8, 2020

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants