aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-11-15 05:04:08 +0300
committereug-vs <eug-vs@keemail.me>2020-11-15 05:04:08 +0300
commit32c538a68062c4a6a0293129d21a6fc619b69f32 (patch)
tree10ba1823a71d1d8cc9de479d14021716083a2d2c
parent1b1a046b542158df270130711e9ef65e6deca27a (diff)
downloadfamcs-kit-32c538a68062c4a6a0293129d21a6fc619b69f32.tar.gz
feat: create user if it does not exist
-rw-r--r--src/containers/BsuFantomSection/LoginForm.tsx6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/containers/BsuFantomSection/LoginForm.tsx b/src/containers/BsuFantomSection/LoginForm.tsx
index 3204a64..69cba90 100644
--- a/src/containers/BsuFantomSection/LoginForm.tsx
+++ b/src/containers/BsuFantomSection/LoginForm.tsx
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import { TextField, Button, Grid } from '@material-ui/core';
import { useAuth } from '../../hooks/useAuth';
+import { post } from '../../requests';
const LoginForm: React.FC = () => {
@@ -16,7 +17,10 @@ const LoginForm: React.FC = () => {
setPassword(event.target.value);
};
- const handleSubmit = () => login(username, password);
+ const handleSubmit = () => login(username, password)
+ .then(success => success || post('/users', { username, password })
+ .then(() => login(username, password))
+ );
return (
<Grid container direction="column" spacing={2}>