After Refresh token request new token doesn't saved/updated in local storage
- 主要言語
- TypeScript
- スター
- 8.1k
- フォーク
- 1.5k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I have Node.js MongoDB Starter Bundle (v04-03-2020)
It use by default NbPasswordAuthStrategy
and
token: {
class: NbAuthOAuth2JWTToken,
key: 'token',
},
_For the sake of simlicity i don't write tokens. I think it doesn't matter_
### Issue type
**I'm submitting a ...** (check one with "x")
* [x ] bug report
* [ ] feature request
### Issue description
**Current behavior:**
After succesful login, access token successfully stored in local storage in such format:
```
{
createdAt: 1591249154000
name: "nb:auth:oauth2:jwt:token"
ownerStrategyName: "email"
value: "{"expires_in":36,"access_token":"...","refresh_token":"..."}"
}
```
After expiration period i see request to backend (endpoint '/refresh-token')
In backend AuthService.js -> refreshToken(token)
i write console.log(token)
```
{
payload: {
expires_in: 36,
access_token: '...',
refresh_token: '...'
},
token: {
expires_in: 36,
access_token: '...',
refresh_token: '...'
},
ownerStrategyName: 'email',
createdAt: '2020-06-04T05:39:14.000Z',
accessTokenPayload: {
id: '5ed887b084294d5fa87dc6f3',
role: 'user',
iat: 1591249154,
exp: 1591249190
}
}
```
First of all it check token format:
```
if (!token.access_token || !token.refresh_token) {
throw new Error('Invalid token format');
}
```
And of course it throw Error
Ok. I made a little change
```
refreshToken(token) {
token = token.token
if (!token.access_token || !token.refresh_token) {
throw new Error('Invalid token format');
}
```
... and it's ok
New token sended to a frontend and I see in a browser console response:
```
{ access_token: "..."
expires_in: 36
refresh_token: "..."}
```
But in local storage tokens left unchanged!
**Expected behavior:**
After refresh token request local storage tokens should be updated and this.tokenService.tokenChange() should fired, but its not happend
**Steps to reproduce:**
Just login as user@user.user and after expiration period of time tokens should be updated in local storage
**Related code:**
```
insert short code snippets here
```
### Other information:
Ubuntu Server 18.04
npm 6.14.4
node v12.17.0
Chrome 83.0.4103.61 (64)
コントリビューションガイド
評価
この issue はまだ評価されていません。