feat: get data from jwt
This commit is contained in:
		| @@ -279,9 +279,9 @@ export const DesktopLayout = observer(() => { | |||||||
|                                     } |                                     } | ||||||
|                                     title={ |                                     title={ | ||||||
|                                         <Text> |                                         <Text> | ||||||
|                                             {store.user.data.email}{" "} |                                             {store.user.data.username} | ||||||
|                                             <Paragraph style={{fontWeight: 400}} type={"secondary-dark"}> |                                             <Paragraph style={{fontWeight: 400}} type={"secondary-dark"}> | ||||||
|                                                 {store.authentication.userData.email} |                                                 {store.authentication.userData.username} | ||||||
|                                             </Paragraph> |                                             </Paragraph> | ||||||
|                                         </Text> |                                         </Text> | ||||||
|                                     } |                                     } | ||||||
| @@ -353,12 +353,13 @@ export const DesktopLayout = observer(() => { | |||||||
|                                         }} |                                         }} | ||||||
|                                         mode="inline" |                                         mode="inline" | ||||||
|                                     > |                                     > | ||||||
|                                         <Menu.Item> |                                         <Menu.Item key={'profile'}> | ||||||
|                                             <Link to="/app/profile"> |                                             <Link to="/app/profile"> | ||||||
|                                                 <span>Profile</span> |                                                 <span>Profile</span> | ||||||
|                                             </Link> |                                             </Link> | ||||||
|                                         </Menu.Item> |                                         </Menu.Item> | ||||||
|                                         <Menu.Item |                                         <Menu.Item | ||||||
|  |                                             key={'logout'} | ||||||
|                                             onClick={() => { |                                             onClick={() => { | ||||||
|                                                 store.authentication.logout(); |                                                 store.authentication.logout(); | ||||||
|                                                 history.push("/login"); |                                                 history.push("/login"); | ||||||
| @@ -372,7 +373,7 @@ export const DesktopLayout = observer(() => { | |||||||
|                                     <Text> |                                     <Text> | ||||||
|                                         {store.user.data.email}{" "} |                                         {store.user.data.email}{" "} | ||||||
|                                         <Paragraph style={{fontWeight: 400}} type={"secondary-dark"}> |                                         <Paragraph style={{fontWeight: 400}} type={"secondary-dark"}> | ||||||
|                                             {/*{store.authentication.userData.full_name}*/} |                                             {store.authentication.userData.username} | ||||||
|                                         </Paragraph> |                                         </Paragraph> | ||||||
|                                     </Text> |                                     </Text> | ||||||
|                                 } |                                 } | ||||||
|   | |||||||
| @@ -41,6 +41,7 @@ export class Authentication { | |||||||
|     try { |     try { | ||||||
|       const result = await http.post('/auth/login').send({username, password}); |       const result = await http.post('/auth/login').send({username, password}); | ||||||
|  |  | ||||||
|  |       this.accessToken = result.body.access_token; | ||||||
|       TokenUtil.setAccessToken(result.body.access_token); |       TokenUtil.setAccessToken(result.body.access_token); | ||||||
|       TokenUtil.persistToken(); |       TokenUtil.persistToken(); | ||||||
|       runInAction(() => { |       runInAction(() => { | ||||||
| @@ -60,5 +61,6 @@ export class Authentication { | |||||||
|     TokenUtil.clearAccessToken(); |     TokenUtil.clearAccessToken(); | ||||||
|     TokenUtil.persistToken(); |     TokenUtil.persistToken(); | ||||||
|     this.isLoggedIn = false; |     this.isLoggedIn = false; | ||||||
|  |     this.accessToken = ''; | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ export class Store { | |||||||
|         TokenUtil.loadToken(); |         TokenUtil.loadToken(); | ||||||
|         if (TokenUtil.accessToken) { |         if (TokenUtil.accessToken) { | ||||||
|             this.authentication.isLoggedIn = true; |             this.authentication.isLoggedIn = true; | ||||||
|  |             this.authentication.accessToken = TokenUtil.accessToken; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user