-
Notifications
You must be signed in to change notification settings - Fork 1
Refresh Token
Leandro Santiago Gomes edited this page Jan 30, 2023
·
1 revision
As an user
I want refresh my tokens
To continue accessing protected content
After a certain time the access tokens are expired. After this expiration, for the user to continue accessing the system, he must send the refreshToken to a refresh route, then receiving new access and refresh tokens
graph TD
r400([400 - Bad Request])
r401([401 - Unauthorized])
r200([200 - Ok])
s((start))
-->|User| s01[Request to refresh token]
-->|API| s02[Check if request is valid]
--> q01{is valid?}
q01 -->|no| r400
q01 -->|yes| q01y[Verify "refreshToken"]
--> q02{is valid?}
q02 -->|no| r401
q02 -->|yes| q02y[Find "userAuth" to "refreshToken"]
--> q03{is found?}
q03 -->|no| r401
q03 -->|yes| q03y[Check if "userAuth" is active]
--> q04{is active?}
q04 -->|no| r401
q04 -->|yes| q04y[Find "user"]
--> q05{is found?}
q05 -->|no| r401
q05 -->|yes| q05y[Check if "user" is active]
--> q06{is active?}
q06 -->|no| r403
q06 -->|yes| q06y[Update "userAuth"]
--> q07[Return new "bearerAuth"] -->r200
interface Request {
method: 'POST'
headers: {
authorization: `Bearer ${string}`
}
}interface Response {
status: 200,
body: {
type: 'Bearer',
accessToken: string
refreshToken: string
}
}