Files
openhuman/src/store/authSlice.ts
T
Steven Enamakel f0a49fc167 Refactor authentication flow to remove localStorage dependencies and improve state management
- Removed localStorage interactions for session tokens and user data in the TelegramLoginButton and authSlice, enhancing security and simplifying the codebase.
- Updated the desktop deep link listener to eliminate localStorage usage for user data, streamlining the authentication process.
- Adjusted the Redux store configuration to remove custom storage for backward compatibility, focusing on a cleaner state management approach.

These changes enhance the application's architecture by centralizing state management and improving maintainability.
2026-01-28 04:31:23 +05:30

26 lines
510 B
TypeScript

import { createSlice, PayloadAction } from '@reduxjs/toolkit';
interface AuthState {
token: string | null;
}
const initialState: AuthState = {
token: null,
};
const authSlice = createSlice({
name: 'auth',
initialState,
reducers: {
setToken: (state, action: PayloadAction<string>) => {
state.token = action.payload;
},
clearToken: (state) => {
state.token = null;
},
},
});
export const { setToken, clearToken } = authSlice.actions;
export default authSlice.reducer;