Skip to content

Commit

Permalink
Fix redir hell
Browse files Browse the repository at this point in the history
  • Loading branch information
lil5 committed Mar 15, 2024
1 parent c6b6757 commit 39abd1e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 30 deletions.
27 changes: 0 additions & 27 deletions frontend/src/stores/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
localRouteMapLine,
sessionAuthUser,
} from "./browser_storage";
import Cookies from "js-cookie";

export enum UserRefreshState {
NeverLoggedIn,
Expand Down Expand Up @@ -48,7 +47,6 @@ export function authLogout() {
return (async () => {
await logout().catch((e) => console.warn(e));
// Remove legacy cookies
Cookies.remove("user_uid");
cookieUserUID.set(undefined);
localRouteMapLine.set(undefined);
$authUser.set(null);
Expand Down Expand Up @@ -103,30 +101,5 @@ export function authUserRefresh(force = false): Promise<UserRefreshState> {
$loading.set(false);
console.log("logged in");
return UserRefreshState.LoggedIn;

// // Astro will set the i18n by path only
// // The home/admin page will redirect to the user's preferred language only
// Cookies.set(KEY_USER_UID, user.uid, cookieOptions);
// $loading.set(false);
// const isChanged = user.i18n ? user.i18n !== i18n.language : false;
// const isUnset = !user.i18n;
// if (!isUnset && isChanged) {
// i18n.changeLanguage(user.i18n);
// }
// if (isUnset || isChanged) {
// userUpdate({
// user_uid: user.uid,
// i18n: i18n.language,
// });
// }
// } catch (err: any) {
// if (err?.status === 401) {
// await authLogout().catch((err) => {
// console.error("force logout failed:", err);
// });
// }
// console.info("force logout");
// return UserRefreshState.ForceLoggedOut;
// }
})();
}
4 changes: 2 additions & 2 deletions server/internal/app/auth/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func CookieRemove(c *gin.Context) {
Value: "",
MaxAge: -1,
Path: "/",
Domain: "",
Domain: app.Config.COOKIE_DOMAIN,
SameSite: http.SameSiteStrictMode,
Secure: app.Config.COOKIE_HTTPS_ONLY,
HttpOnly: true,
Expand All @@ -33,7 +33,7 @@ func CookieRemove(c *gin.Context) {
Value: "",
MaxAge: -1,
Path: "/",
Domain: "",
Domain: app.Config.COOKIE_DOMAIN,
SameSite: http.SameSiteStrictMode,
Secure: app.Config.COOKIE_HTTPS_ONLY,
HttpOnly: false,
Expand Down
1 change: 0 additions & 1 deletion server/internal/controllers/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ func Logout(c *gin.Context) {
_, ok := auth.TokenReadFromRequest(c)
if !ok {
c.String(http.StatusBadRequest, "No token received")
return
}

auth.CookieRemove(c)
Expand Down

0 comments on commit 39abd1e

Please sign in to comment.