diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 50d2d3d1..9e772c96 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -13,7 +13,6 @@ import NoEncryptionGmailerrorredIcon from "@mui/icons-material/NoEncryptionGmail import SearchIcon from "@mui/icons-material/Search"; import { useMsal } from "@azure/msal-react"; import AzureLogin from "../../views/Login/AzureLogin"; -import { Person } from "@microsoft/mgt-react"; const HeaderComponent: FC = () => { const replace = useNavigate(); diff --git a/src/views/Login/AzureLogin.tsx b/src/views/Login/AzureLogin.tsx index 37248db4..b1e438f1 100644 --- a/src/views/Login/AzureLogin.tsx +++ b/src/views/Login/AzureLogin.tsx @@ -37,57 +37,57 @@ const AzureLogin: React.FC = () => { }; //makes user if logged in user has access to do so - const createUser = async () => { - const apiUrl = "https://graph.microsoft.com/v1.0/users"; - const newUser = { - accountEnabled: true, - displayName: "John Doe2", - mailNickname: "john.doe2", - userPrincipalName: "john.doe2@fgsamfundet.onmicrosoft.com", - passwordProfile: { - forceChangePasswordNextSignIn: true, - password: "A_Strong_Password123", - }, - }; - - try { - const activeAccount = instance.getActiveAccount(); - - if (!activeAccount) { - console.error("No active account. Please log in."); - return; - } - - const accessToken = await instance - .acquireTokenSilent({ - account: activeAccount, - scopes: ["User.Read"], - }) - .catch((error) => { - console.error("Error acquiring token silently:", error.message); - throw error; - }); - - if (accessToken) { - const response = await fetch(apiUrl, { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${accessToken.accessToken}`, - }, - body: JSON.stringify(newUser), - }); - - if (response.ok) { - console.log("User created successfully"); - } else { - console.error("Error creating user:", await response.text()); - } - } - } catch (error: any) { - console.error("Error:", error.message); - } - }; + // const createUser = async () => { + // const apiUrl = "https://graph.microsoft.com/v1.0/users"; + // const newUser = { + // accountEnabled: true, + // displayName: "John Doe2", + // mailNickname: "john.doe2", + // userPrincipalName: "john.doe2@fgsamfundet.onmicrosoft.com", + // passwordProfile: { + // forceChangePasswordNextSignIn: true, + // password: "A_Strong_Password123", + // }, + // }; + + // try { + // const activeAccount = instance.getActiveAccount(); + + // if (!activeAccount) { + // console.error("No active account. Please log in."); + // return; + // } + + // const accessToken = await instance + // .acquireTokenSilent({ + // account: activeAccount, + // scopes: ["User.Read"], + // }) + // .catch((error) => { + // console.error("Error acquiring token silently:", error.message); + // throw error; + // }); + + // if (accessToken) { + // const response = await fetch(apiUrl, { + // method: "POST", + // headers: { + // "Content-Type": "application/json", + // Authorization: `Bearer ${accessToken.accessToken}`, + // }, + // body: JSON.stringify(newUser), + // }); + + // if (response.ok) { + // console.log("User created successfully"); + // } else { + // console.error("Error creating user:", await response.text()); + // } + // } + // } catch (error: any) { + // console.error("Error:", error.message); + // } + // }; //get function call for user profile currently logged in useEffect(() => {