mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
Simplify
This commit is contained in:
parent
09d05b0d04
commit
405e452eee
@ -4,37 +4,36 @@ import EnteSpinner from "@ente/shared/components/EnteSpinner";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect } from "react";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
const AccountHandoff = () => {
|
||||
const Page: React.FC = () => {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
const pkg = urlParams.get("package");
|
||||
if (!pkg) return;
|
||||
setData(LS_KEYS.CLIENT_PACKAGE, { name: pkg });
|
||||
HTTPService.setHeaders({
|
||||
"X-Client-Package": pkg,
|
||||
});
|
||||
|
||||
try {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const token = urlParams.get("token");
|
||||
if (!token) {
|
||||
throw new Error("token not found");
|
||||
}
|
||||
|
||||
const user = getData(LS_KEYS.USER) || {};
|
||||
user.token = token;
|
||||
|
||||
setData(LS_KEYS.USER, user);
|
||||
|
||||
router.push("/passkeys/setup");
|
||||
} catch (e) {
|
||||
log.error("Failed to deserialize and set passed user data", e);
|
||||
router.push("/login");
|
||||
if (pkg) {
|
||||
// TODO-PK: mobile is not passing it. is that expected?
|
||||
setData(LS_KEYS.CLIENT_PACKAGE, { name: pkg });
|
||||
HTTPService.setHeaders({
|
||||
"X-Client-Package": pkg,
|
||||
});
|
||||
}
|
||||
|
||||
const token = urlParams.get("token");
|
||||
if (!token) {
|
||||
log.error("Missing accounts token");
|
||||
router.push("/login");
|
||||
return;
|
||||
}
|
||||
|
||||
const user = getData(LS_KEYS.USER) || {};
|
||||
user.token = token;
|
||||
|
||||
setData(LS_KEYS.USER, user);
|
||||
|
||||
router.push("/passkeys/setup");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
@ -44,4 +43,4 @@ const AccountHandoff = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default AccountHandoff;
|
||||
export default Page;
|
||||
|
Loading…
x
Reference in New Issue
Block a user