Skip to content

Commit

Permalink
Reintroduce CSRF token check into getMe
Browse files Browse the repository at this point in the history
Reintroduces CSRF cookie check in `getMe` API call
  • Loading branch information
allanlasser committed Jan 26, 2024
1 parent d301acd commit 733c9cc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/api/orgAndUser.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import session from "./session.js";
import session, { cookiesEnabled, getCsrfToken } from "./session.js";
import { USER_EXPAND, ORG_EXPAND, DEFAULT_EXPAND } from "./common.js";
import { queryBuilder } from "@/util/url.js";
import { grabAllPages } from "@/util/paginate.js";
import { apiUrl } from "./base.js";

export async function getMe(expand = DEFAULT_EXPAND) {
// Check that the user is logged in via cookies
if (cookiesEnabled && !getCsrfToken()) return null;
// Check that the user is logged in via network request
const { status, data } = await session.get(
queryBuilder(apiUrl(`users/me/`), { expand }),
);
Expand Down

0 comments on commit 733c9cc

Please sign in to comment.