Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/Login.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState, useRef } from "react";
import {useNavigate} from 'react-router-dom';
import Form from "react-validation/build/form";
import Input from "react-validation/build/input";
import CheckButton from "react-validation/build/button";

import AuthService from "../services/auth.service";

const required = (value) => {
Expand All @@ -18,6 +18,7 @@ const required = (value) => {
const Login = (props) => {
const form = useRef();
const checkBtn = useRef();
const navigate = useNavigate();

const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
Expand All @@ -41,11 +42,12 @@ const Login = (props) => {
setLoading(true);

form.current.validateAll();


if (checkBtn.current.context._errors.length === 0) {
AuthService.login(username, password).then(
() => {
props.history.push("/profile");
navigate("/profile");
window.location.reload();
},
(error) => {
Expand Down