Skip to content

Commit 2b5463a

Browse files
committed
migration
1 parent 2e0869b commit 2b5463a

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

front/src/contexts/auth/consumerHOC/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function withAuth(/* additionnal args if needed */) {
1616

1717
return (
1818
<AuthContextConsumer>
19-
{(fromAuthProps: AuthContextProps) => (
19+
{(fromAuthProps: Partial<AuthContextProps>) => (
2020
<BaseComponent {...fromAuthProps} {...passProps} />
2121
)}
2222
</AuthContextConsumer>

front/src/contexts/auth/providerComponent/index.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AuthContextProvider, AuthData } from '../context';
33
import auth from '../../../services/auth';
44
import { devToolsStore } from '../../withDevTools';
55

6-
// #region types
6+
// #region types
77
export type AuthProviderProps = {
88
initialState: {} & AuthData;
99
};
@@ -68,19 +68,17 @@ export default class AuthProvider extends Component<
6868
// #endregion
6969

7070
checkIsAuthenticated = (): boolean => {
71-
const checkUserHasId = (user: User) => user?.id ?? '';
71+
const checkUserHasId = (user: User) => user.id;
7272
const user = auth.getUserInfo() ? auth.getUserInfo() : null;
73-
const isAuthenticated = auth.getToken() && checkUserHasId(user);
73+
const isAuthenticated = !!(auth.getToken() && checkUserHasId(user));
7474

7575
devToolsStore &&
7676
devToolsStore.dispatch({
7777
type: 'AUTH_CHECK_IS_AUTHENTICATED',
7878
state: { ...this.state, isAuthenticated },
7979
});
8080

81-
this.setState({
82-
isAuthenticated,
83-
});
81+
this.setState({ isAuthenticated });
8482
return isAuthenticated;
8583
};
8684

@@ -94,9 +92,7 @@ export default class AuthProvider extends Component<
9492
state: { ...this.state, isExpiredToken },
9593
});
9694

97-
this.setState({
98-
isExpiredToken,
99-
});
95+
this.setState({ isExpiredToken });
10096
return isExpiredToken;
10197
};
10298

0 commit comments

Comments
 (0)