From cc91abb0ca403b7d7180b0e24fe126bd35ce20ab Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Thu, 25 Jun 2020 21:46:06 +0300
Subject: feat: add rememberMe switch

---
 src/index.tsx | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

(limited to 'src/index.tsx')

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);
   };
-- 
cgit v1.2.3

