mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-30 23:14:37 +00:00
- 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.
26 lines
510 B
TypeScript
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;
|