Conversation
Add 'id' command to show user-id, as well as log it during authentication.
|
I can split this into two different PRs if you want, one for the fix and one for the feature - not sure how you like to manage changes :) |
| // return nil, fmt.Errorf(msg) | ||
| // } | ||
|
|
||
| return nil, nil |
There was a problem hiding this comment.
Having the interface returned here be nil causes the jwt.Parse method to always fail - if we want to parse the token without verifying we need to use ParseUnverified.
|
Could we change the |
Not sure |
|
I'm not entirely sure it's right to be under |
I can stand behind this to be honest, I think as it stands authenticate can be reached with out users, so it is a bit redundant to also have it inside of users. If we remove it from the user category, I think it would be okay to have id as a stand alone too. Maybe rename the command to user_id or potentially, current_user? |
id command to show user_idinfo command to show user info
|
As per discussion and PRVD-48, I've modified this to be |
| return &user, nil | ||
| } | ||
|
|
||
| return nil, fmt.Errorf("please authenticate to retrieve your user info") |
There was a problem hiding this comment.
should we prompt for authentication instead of error-ing out?
There was a problem hiding this comment.
Nothing else does - this should be consistent. We can change design in a new PR for all of the auth failures if desired, but this isn't the place to do that.
zk-bits
left a comment
There was a problem hiding this comment.
One minor comment, on design, lgtm otherwise.
|
Please squash all commits into one before merging. |
This is easily fixed by doing a "squash and merge" in GitHub - this will keep the commit history in this PR for future reference while the main branch only gets the one squashed commit. |
isTokenExpiredwas not properly calling the JWT parser, and as a result an error was always returned and this led the function to always returnfalse.New command
infoadded that prints out the currently auth'd user's data. Also logs the User ID when callingauthenticate.Examples: