Přesun autentizace na server
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React, { useCallback, useRef } from 'react';
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { useAuth } from './context/auth';
|
||||
import { login } from './Api';
|
||||
import './Login.css';
|
||||
|
||||
/**
|
||||
@@ -10,10 +11,14 @@ export default function Login() {
|
||||
const auth = useAuth();
|
||||
const loginRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const doLogin = useCallback(() => {
|
||||
const doLogin = useCallback(async () => {
|
||||
const length = loginRef?.current?.value && loginRef?.current?.value.length && loginRef.current.value.replace(/\s/g, '').length
|
||||
if (length) {
|
||||
auth?.setLogin(loginRef.current.value);
|
||||
// TODO odchytávat cokoliv mimo 200
|
||||
const token = await login(loginRef.current.value);
|
||||
if (token) {
|
||||
auth?.setToken(token);
|
||||
}
|
||||
}
|
||||
}, [auth]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user