Migrace klienta na OpenAPI
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useCallback, useEffect, useRef } from 'react';
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { useAuth } from './context/auth';
|
||||
import { login } from './api/Api';
|
||||
import { login } from '../../types';
|
||||
import './Login.css';
|
||||
|
||||
/**
|
||||
@@ -14,9 +14,10 @@ export default function Login() {
|
||||
useEffect(() => {
|
||||
if (auth && !auth.login) {
|
||||
// Vyzkoušíme přihlášení "naprázdno", pokud projde, přihlásili nás trusted headers
|
||||
login().then(token => {
|
||||
login().then(response => {
|
||||
const token = response.data;
|
||||
if (token) {
|
||||
auth?.setToken(token);
|
||||
auth?.setToken(token as unknown as string); // TODO vyřešit, API definice je špatně, je to skutečně string
|
||||
}
|
||||
}).catch(error => {
|
||||
// nezajímá nás
|
||||
@@ -27,9 +28,9 @@ export default function Login() {
|
||||
const doLogin = useCallback(async () => {
|
||||
const length = loginRef?.current?.value.length && loginRef.current.value.replace(/\s/g, '').length
|
||||
if (length) {
|
||||
const token = await login(loginRef.current?.value);
|
||||
if (token) {
|
||||
auth?.setToken(token);
|
||||
const response = await login({ body: { login: loginRef.current?.value } });
|
||||
if (response.data) {
|
||||
auth?.setToken(response.data as unknown as string); // TODO vyřešit
|
||||
}
|
||||
}
|
||||
}, [auth]);
|
||||
|
||||
Reference in New Issue
Block a user