diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-25 21:46:06 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-25 21:47:12 +0300 |
commit | cc91abb0ca403b7d7180b0e24fe126bd35ce20ab (patch) | |
tree | 662a158be971e0771de2c44db46e1dfe3b2c1e4c /src/index.tsx | |
parent | f24ea161fd2aef6ba75418c965d444ccbfd53fac (diff) | |
download | which-ui-cc91abb0ca403b7d7180b0e24fe126bd35ce20ab.tar.gz |
feat: add rememberMe switch
Diffstat (limited to 'src/index.tsx')
-rw-r--r-- | src/index.tsx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/index.tsx b/src/index.tsx index 50b19f7..2747bfa 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -55,7 +55,7 @@ const App: React.FC = () => { } }; - const logIn = (username: string, password: string): Promise<boolean> => { + const logIn = (username: string, password: string, remember?: boolean): Promise<boolean> => { return post('/authentication', { strategy: 'local', username, @@ -64,9 +64,11 @@ const App: React.FC = () => { const me = response.data.user; const token = response.data.accessToken; setUser(me); - localStorage.setItem('userId', me._id); - localStorage.setItem('token', token); navigate('profile', me._id); + if (remember) { + localStorage.setItem('userId', me._id); + localStorage.setItem('token', token); + } return true; }).catch(() => false); }; |