mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
Set for accounts headers
This commit is contained in:
parent
242c669de4
commit
1e8ec0e814
@ -1,4 +1,5 @@
|
||||
import { CustomHead } from "@/next/components/Head";
|
||||
import { setClientPackageNameForAuthenticatedRequests } from "@/next/http";
|
||||
import { setupI18n } from "@/next/i18n";
|
||||
import { logUnhandledErrorsAndRejections } from "@/next/log-web";
|
||||
import { appTitle, type AppName, type BaseAppContextT } from "@/next/types/app";
|
||||
@ -64,10 +65,11 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
}, []);
|
||||
|
||||
const setupPackageName = () => {
|
||||
const pkg = localStorage.getItem("clientPackage");
|
||||
if (!pkg) return;
|
||||
const clientPackage = localStorage.getItem("clientPackage");
|
||||
if (!clientPackage) return;
|
||||
setClientPackageNameForAuthenticatedRequests(clientPackage);
|
||||
HTTPService.setHeaders({
|
||||
"X-Client-Package": pkg,
|
||||
"X-Client-Package": clientPackage,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { setClientPackageNameForAuthenticatedRequests } from "@/next/http";
|
||||
import log from "@/next/log";
|
||||
import { VerticallyCentered } from "@ente/shared/components/Container";
|
||||
import EnteSpinner from "@ente/shared/components/EnteSpinner";
|
||||
@ -20,6 +21,7 @@ const Page: React.FC = () => {
|
||||
if (clientPackage) {
|
||||
// TODO-PK: mobile is not passing it. is that expected?
|
||||
localStorage.setItem("clientPackage", clientPackage);
|
||||
setClientPackageNameForAuthenticatedRequests(clientPackage);
|
||||
HTTPService.setHeaders({
|
||||
"X-Client-Package": clientPackage,
|
||||
});
|
||||
@ -34,7 +36,6 @@ const Page: React.FC = () => {
|
||||
|
||||
const user = getData(LS_KEYS.USER) || {};
|
||||
user.token = token;
|
||||
|
||||
setData(LS_KEYS.USER, user);
|
||||
|
||||
router.push("/passkeys");
|
||||
|
@ -96,9 +96,6 @@ export const registerPasskey = async (name: string) => {
|
||||
};
|
||||
|
||||
export const getPasskeyRegistrationOptions = async () => {
|
||||
const clientPackage = localStorage.getItem("clientPackage")
|
||||
const token = ensure(getToken());
|
||||
|
||||
try {
|
||||
const token = getToken();
|
||||
if (!token) return;
|
||||
|
@ -21,6 +21,14 @@ export const setAppNameForAuthenticatedRequests = (appName: AppName) => {
|
||||
_clientPackageName = clientPackageName[appName];
|
||||
};
|
||||
|
||||
/**
|
||||
* Variant of {@link setAppNameForAuthenticatedRequests} that sets directly sets
|
||||
* the client package name to the provided string.
|
||||
*/
|
||||
export const setClientPackageNameForAuthenticatedRequests = (p: string) => {
|
||||
_clientPackageName = p;
|
||||
};
|
||||
|
||||
/**
|
||||
* Forget the effects of a previous {@link setAppNameForAuthenticatedRequests}.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user