use the new backend services

This commit is contained in:
Sven Czarnian
2022-11-04 15:28:47 +01:00
parent 7807c2784c
commit 6882c41089
2 changed files with 6 additions and 16 deletions

View File

@@ -1,7 +1,6 @@
import axios from 'axios';
import { createContext, Dispatch, SetStateAction, useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Configuration } from '../services';
import { Auth } from '../services';
import { User } from '../types';
const AuthContext = createContext<{
@@ -30,12 +29,8 @@ export const AuthProvider = ({ children }: { children: any }) => {
const navigate = useNavigate();
useEffect(() => {
axios.get<User>(`${Configuration.resourceServer}/auth/user`, {
headers: {
Authorization: `Bearer ${sessionStorage.getItem('token')}`,
},
}).then((response) => {
setAuth({ valid: true, user: response.data });
Auth.user().then((user) => {
setAuth({ valid: true, user });
}).catch(() => {
setAuth({
valid: false,