Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use auth cookie set by backend instead of jwt (fixes #2193) #2208

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/shared/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const updateUnreadCountsInterval = 30000;
export const fetchLimit = 20;
export const relTags = "noopener nofollow";
export const emDash = "\u2014";
export const authCookieName = "jwt";
export const authCookieName = "auth";

// No. of max displayed communities per
// page on route "/communities"
Expand Down
7 changes: 4 additions & 3 deletions src/shared/services/UserService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isAuthPath } from "@utils/app";
import { clearAuthCookie, isBrowser, setAuthCookie } from "@utils/browser";
import { isBrowser } from "@utils/browser";
import * as cookie from "cookie";
import jwt_decode from "jwt-decode";
import { LoginResponse, MyUserInfo } from "lemmy-js-client";
Expand Down Expand Up @@ -40,7 +40,6 @@ export class UserService {

if (isBrowser() && res.jwt) {
showToast && toast(I18NextService.i18n.t("logged_in"));
setAuthCookie(res.jwt);
this.#setJwtInfo();
}
}
Expand All @@ -50,7 +49,9 @@ export class UserService {
this.myUserInfo = undefined;

if (isBrowser()) {
clearAuthCookie();
// TODO: call logout here
// https://github.com/LemmyNet/lemmy-js-client/pull/208
//HttpService.client.logout()
}

if (isAuthPath(location.pathname)) {
Expand Down
10 changes: 0 additions & 10 deletions src/shared/utils/browser/clear-auth-cookie.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/shared/utils/browser/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import canShare from "./can-share";
import clearAuthCookie from "./clear-auth-cookie";
import dataBsTheme from "./data-bs-theme";
import isBrowser from "./is-browser";
import isDark from "./is-dark";
import loadCss from "./load-css";
import platform from "./platform";
import restoreScrollPosition from "./restore-scroll-position";
import saveScrollPosition from "./save-scroll-position";
import setAuthCookie from "./set-auth-cookie";
import share from "./share";

export {
canShare,
clearAuthCookie,
dataBsTheme,
isBrowser,
isDark,
loadCss,
platform,
restoreScrollPosition,
saveScrollPosition,
setAuthCookie,
share,
};
12 changes: 0 additions & 12 deletions src/shared/utils/browser/set-auth-cookie.ts

This file was deleted.