Версия 0.0.2
This commit is contained in:
commit
7b9c998224
530 changed files with 424916 additions and 0 deletions
20
FRONT/BUILD/resources/app/src/utils/checkAdmin.ts
Normal file
20
FRONT/BUILD/resources/app/src/utils/checkAdmin.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { useIpStore } from "../store";
|
||||
import { useAdminStore } from "../store/adminStore";
|
||||
import { useEffect } from "react";
|
||||
import { NetworkService } from "../api/request";
|
||||
|
||||
export const useCheckAdmin = () => {
|
||||
const { ipAddress } = useIpStore()
|
||||
const { setAdmin } = useAdminStore()
|
||||
|
||||
return async () => {
|
||||
const response = await NetworkService.whoami(ipAddress);
|
||||
console.log(response.data);
|
||||
if(response.status == 401){
|
||||
setAdmin(false)
|
||||
}
|
||||
else{
|
||||
setAdmin(response.data.user.is_admin);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue