Skip to content

Commit

Permalink
Merge pull request #81 from zetonteam/session-019-fix_token_authentic…
Browse files Browse the repository at this point in the history
…ation

 session-019-fix_token_authentication
  • Loading branch information
mniegrzybowska authored Sep 8, 2024
2 parents f158ef0 + c701de0 commit c27254a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/providers/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from './authenticationReducer.ts';

export const AuthenticationContext = createContext<Authentication>({
token: null,
token: "",
});
export const TokenDispatchContext = createContext<React.Dispatch<TokenAction>>(
{} as React.Dispatch<TokenAction>
Expand All @@ -23,9 +23,9 @@ const AuthProvider = ({ children }: { children: React.ReactNode }) => {

const [authentication, dispatch] = useReducer<AuthenticationReducer>(
authenticationReducer,
{
token: null,
}
{
token: ""
}
);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/authenticationReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const authenticationReducer: AuthenticationReducer = (
case 'set':
return { token: action.token };
case 'clear':
return { token: null };
return { token: "" };
default:
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
throw new Error(`Invalid action type ${action.type}`);
Expand Down
4 changes: 2 additions & 2 deletions src/providers/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export interface Authentication {
token: string | null;
token: string;
}

export interface TokenAction {
type: 'set' | 'clear';
token: string | null;
token: string;
}

0 comments on commit c27254a

Please sign in to comment.