From bf5d2add77b8ea75a19def82e1c6fb74d72e3e03 Mon Sep 17 00:00:00 2001 From: Arthi-chaud Date: Mon, 15 Aug 2022 10:15:00 +0200 Subject: [PATCH] Front: Type authentication string for more clarity --- front/models/AuthToken.ts | 3 +++ front/state/UserSlice.ts | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 front/models/AuthToken.ts diff --git a/front/models/AuthToken.ts b/front/models/AuthToken.ts new file mode 100644 index 0000000..25bb4f9 --- /dev/null +++ b/front/models/AuthToken.ts @@ -0,0 +1,3 @@ +type AuthToken = string; + +export default AuthToken; \ No newline at end of file diff --git a/front/state/UserSlice.ts b/front/state/UserSlice.ts index 46da6ee..a7904f7 100644 --- a/front/state/UserSlice.ts +++ b/front/state/UserSlice.ts @@ -1,12 +1,13 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import AuthToken from '../models/AuthToken'; export const userSlice = createSlice({ name: 'user', initialState: { - token: undefined as string | undefined + token: undefined as AuthToken | undefined }, reducers: { - setUserToken: (state, action: PayloadAction) => { + setUserToken: (state, action: PayloadAction) => { state.token = action.payload; }, unsetUserToken: (state) => {