aboutsummaryrefslogtreecommitdiff
path: root/src/index.tsx
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-25 21:46:06 +0300
committereug-vs <eug-vs@keemail.me>2020-06-25 21:47:12 +0300
commitcc91abb0ca403b7d7180b0e24fe126bd35ce20ab (patch)
tree662a158be971e0771de2c44db46e1dfe3b2c1e4c /src/index.tsx
parentf24ea161fd2aef6ba75418c965d444ccbfd53fac (diff)
downloadwhich-ui-cc91abb0ca403b7d7180b0e24fe126bd35ce20ab.tar.gz
feat: add rememberMe switch
Diffstat (limited to 'src/index.tsx')
-rw-r--r--src/index.tsx8
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);
};