mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-26 12:21:03 +00:00
feat: handle login from deeplink
This commit is contained in:
17
src/main/events/auth/signout.ts
Normal file
17
src/main/events/auth/signout.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { userAuthRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { HydraApi } from "@main/services/hydra-api";
|
||||
import { WindowManager } from "@main/services";
|
||||
|
||||
const signout = async (_event: Electron.IpcMainInvokeEvent): Promise<void> => {
|
||||
await Promise.all([
|
||||
userAuthRepository.delete({ id: 1 }),
|
||||
HydraApi.post("/auth/logout"),
|
||||
]).finally(() => {
|
||||
if (WindowManager.mainWindow) {
|
||||
WindowManager.mainWindow.webContents.send("on-signout");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
registerEvent("signout", signout);
|
||||
@@ -40,7 +40,8 @@ import "./download-sources/validate-download-source";
|
||||
import "./download-sources/add-download-source";
|
||||
import "./download-sources/remove-download-source";
|
||||
import "./download-sources/sync-download-sources";
|
||||
import "./profile/get-user-profile";
|
||||
import "./auth/signout";
|
||||
import "./user/get-user";
|
||||
import "./profile/get-me";
|
||||
|
||||
ipcMain.handle("ping", () => "pong");
|
||||
|
||||
@@ -5,7 +5,7 @@ import { UserProfile } from "@types";
|
||||
import { convertSteamGameToCatalogueEntry } from "../helpers/search-games";
|
||||
import { getSteamAppAsset } from "@main/helpers";
|
||||
|
||||
const getUserProfile = async (
|
||||
const getUser = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
username: string
|
||||
): Promise<UserProfile | null> => {
|
||||
@@ -53,4 +53,4 @@ const getUserProfile = async (
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("getUserProfile", getUserProfile);
|
||||
registerEvent("getUser", getUser);
|
||||
Reference in New Issue
Block a user