-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth-flow.txt
51 lines (39 loc) · 1.21 KB
/
auth-flow.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
getItemFromLS()
saveItemToLS()
decodeAccessToken()
authService.refreshToken()
saveTokens() {
saveItemToLS()
dispatch(authSuccess())?
}
1. ON APP LOAD / PAGE REFRESH +
getItemFromLS("accessToken")
getItemFromLS("refreshToken")
Have accessToken && refreshToken?
YES NO
decodeAccessToken() Go to signin page
accessToken expired?
YES NO
authService.refreshToken() put decoded accessToken and refreshToken to store
API response success?
YES NO
decodeAccessToken() Go to signin page
saveTokens()
------------
2. ON SIGN IN +
send credentials
response success?
YES NO
decodeAccessToken() Show errors
saveTokens()
redirect to posts page
-----------------
3. 401 error from server during request
error === token expired?
YES NO
get refreshToken from store pass error down
authService.refreshToken()
API response success?
YES NO
decodeAccessToken() Go to signin page
saveTokens()