main
Last change
on this file was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago |
Pred finalna verzija
|
-
Property mode
set to
100644
|
File size:
744 bytes
|
Line | |
---|
1 | import HttpService from "../net/HttpService.js";
|
---|
2 | import config from "../net/netconfig.js";
|
---|
3 |
|
---|
4 | export const verifyToken = async (setIsAuthenticated,setUsername,setLoading) => {
|
---|
5 | const token = localStorage.getItem("token");
|
---|
6 | const httpService = new HttpService();
|
---|
7 |
|
---|
8 | try {
|
---|
9 | const response = await httpService.get(`${config.auth.verify}?token=${token}`);
|
---|
10 | if (response.username) {
|
---|
11 | setIsAuthenticated(true);
|
---|
12 | setUsername(response.username)
|
---|
13 | console.log("/verify resp: ",response.username);
|
---|
14 | } else {
|
---|
15 | setIsAuthenticated(false);
|
---|
16 | setLoading(false);
|
---|
17 | }
|
---|
18 | } catch (error) {
|
---|
19 | setIsAuthenticated(false);
|
---|
20 | } finally {
|
---|
21 | setLoading(false);
|
---|
22 | }
|
---|
23 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.