Skip to content

Commit

Permalink
Saving token in sessions storage (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
javipacheco authored Sep 11, 2023
1 parent f8244d9 commit e7f4aa3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/web/src/state/Settings/SettingsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type Settings = {
type SettingsContextType = [Settings, Dispatch<SetStateAction<Settings>>];

export const initialSettings: Settings = {
apiKey: undefined,
apiKey: sessionStorage.getItem('apiKey') || '',
};

const SettingsContext = createContext<SettingsContextType>([
Expand All @@ -29,6 +29,7 @@ const SettingsProvider = ({children}: { children: ReactNode }) => {

useEffect(() => {
console.info('Settings changed', {...settings});
sessionStorage.setItem('apiKey', settings.apiKey || '');
}, [settings]);

return (
Expand Down

0 comments on commit e7f4aa3

Please sign in to comment.