Skip to content

Commit

Permalink
#57 Add setTokenTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jul 5, 2023
1 parent 01a0ef6 commit 9d005a8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pages/auth/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import axios from "axios";
import { useHistory } from "react-router-dom/";
import { useSetCurrentUser } from "../../contexts/CurrentUserContext";
import { useRedirect } from "../../hooks/useRedirect";
import { setTokenTimestamp } from "../../utils/utils";

function LogInForm() {
const SetCurrentUser = useSetCurrentUser();
useRedirect('loggedIn')
useRedirect("loggedIn");

const [logInData, setLogInData] = useState({
username: "",
Expand All @@ -45,6 +46,7 @@ function LogInForm() {
try {
const { data } = await axios.post("/dj-rest-auth/login/", logInData);
SetCurrentUser(data.user);
setTokenTimestamp(data);
history.goBack();
} catch (err) {
setErrors(err.response?.data);
Expand Down Expand Up @@ -107,6 +109,7 @@ function LogInForm() {
className={alertStyles["alert-warning-custom"]}
key={idx}
>
submi
{message}
</Alert>
))}
Expand Down

0 comments on commit 9d005a8

Please sign in to comment.