aboutsummaryrefslogtreecommitdiff
path: root/src/index.tsx
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-15 17:27:11 +0300
committereug-vs <eug-vs@keemail.me>2020-06-15 17:27:11 +0300
commitdd0c6babb832772cb017171476b2629ef00ee147 (patch)
treea4bc64592dd16ae2705a56dc4c71ac8f55808b55 /src/index.tsx
parentd547ea8b3acffa30fa44e0715661490d066bf580 (diff)
downloadwhich-ui-dd0c6babb832772cb017171476b2629ef00ee147.tar.gz
feat: invalidate from on error
Diffstat (limited to 'src/index.tsx')
-rw-r--r--src/index.tsx9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/index.tsx b/src/index.tsx
index b9204b6..f28aff8 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -52,8 +52,8 @@ const App: React.FC = () => {
}
};
- const logIn = (name: string, password: string) => {
- post('/authentication', {
+ const logIn = (name: string, password: string): Promise<boolean> => {
+ return post('/authentication', {
strategy: 'local',
name,
password
@@ -65,7 +65,8 @@ const App: React.FC = () => {
localStorage.setItem('userId', user._id);
localStorage.setItem('token', accessToken);
navigate('profile', user._id);
- });
+ return true;
+ }).catch(error => false);
};
const logOut = () => {
@@ -91,7 +92,7 @@ const App: React.FC = () => {
<div className={classes.root}>
{ page.prefix === 'profile' && <ProfilePage logOut={logOut} id={page.id} navigate={navigate} /> }
{ page.prefix === 'feed' && <FeedPage navigate={navigate} /> }
- { page.prefix === 'auth' && <AuthPage logIn={logIn} navigate={navigate} /> }
+ { page.prefix === 'auth' && <AuthPage logIn={logIn} /> }
</div>
</ThemeProvider>
);