fix(auth): cookie expiry and renewal (#1527)

* fix(auth/web): logout when expired/invalid/no cookie is present

* fix(auth/web): specify error message in invalid cookie

* fix(auth/web): reset error boundary on login

* fix(auth/web): fix onboarding

* chore: code cleanup

* fix(web): revert tanstack/router to 1.31.0

* refactor(web): remove react-error-boundary

* feat(auth): refresh cookie when close to expiry

* enhancement(web): specify defaultError message in HttpClient

* fix(web): use absolute paths for router links (#1530)

* chore(web): bump `@tanstack/react-router` to `1.31.6`

* fix(web): settings routes

* fix(web): filter routes

* fix(web): remove unused ReleasesIndexRoute

* chore(web): add documentation for HttpClient

* chore(lint): remove unnecessary whitespace
This commit is contained in:
martylukyy 2024-05-08 10:38:02 +02:00 committed by GitHub
parent 3dab295387
commit 8120c33f6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 364 additions and 366 deletions

View file

@ -8,12 +8,11 @@ import { Form, Formik } from "formik";
import toast from "react-hot-toast";
import { UserIcon } from "@heroicons/react/24/solid";
import { SettingsAccountRoute } from "@app/routes";
import { AuthContext } from "@utils/Context";
import { APIClient } from "@api/APIClient";
import { Section } from "./_components";
import { PasswordField, TextField } from "@components/inputs";
import Toast from "@components/notifications/Toast";
import { AuthContext } from "@utils/Context";
const AccountSettings = () => (
<Section
@ -35,7 +34,7 @@ interface InputValues {
}
function Credentials() {
const ctx = SettingsAccountRoute.useRouteContext()
const username = AuthContext.useSelector((s) => s.username);
const validate = (values: InputValues) => {
const errors: Record<string, string> = {};
@ -52,7 +51,7 @@ function Credentials() {
const logoutMutation = useMutation({
mutationFn: APIClient.auth.logout,
onSuccess: () => {
AuthContext.logout();
AuthContext.reset();
toast.custom((t) => (
<Toast type="success" body="User updated successfully. Please sign in again!" t={t} />
@ -78,7 +77,7 @@ function Credentials() {
<div className="px-2 pb-6 bg-white dark:bg-gray-800">
<Formik
initialValues={{
username: ctx.auth.username!,
username: username,
newUsername: "",
oldPassword: "",
newPassword: "",