cleaning a bunch of the auth stuff but not done

This commit is contained in:
talksik
2022-04-01 11:10:37 -04:00
parent 95fe01af03
commit 685c03e505
18 changed files with 554 additions and 678 deletions
+3 -2
View File
@@ -3,12 +3,13 @@
enum Channels {
ACTIVATE_LOG_IN = "ACTIVATE_LOG_IN",
AUTH_TOKENS = "AUTH_TOKENS",
GOOGLE_AUTH_TOKENS = "GOOGLE_AUTH_TOKENS",
RESIZE_WINDOW = "RESIZE_WINDOW",
}
export enum STORE_ITEMS {
AUTH_TOKENS = "AUTH_TOKENS",
GOOGLE_AUTH_TOKENS = "GOOGLE_AUTH_TOKENS",
AUTH_SESSION_JWT = "AUTH_SESSION_JWT",
}
export const Dimensions = {
+5 -27
View File
@@ -9,36 +9,14 @@ const myApiOauth = new ElectronGoogleOAuth2(
"423533244953-banligobgbof8hg89i6cr1l7u0p7c2pk.apps.googleusercontent.com",
"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",
[""],
{ successRedirectURL: "https://usenirvana.com" }
{ successRedirectURL: "http://localhost:3000/auth/success" }
);
// FRESH LOGIN...either tokens of user expired or never had them
export async function handleLogin() {
// read saved refresh token if any
// todo: fix this...should be working
const authTokens = await store.get(STORE_ITEMS.AUTH_TOKENS);
// todo: remove this when I have way of getting access token from a refresh token
// if (refreshToken) {
// console.log("have a refresh token from user auth previously", refreshToken);
// // myApiOauth.setTokens({ refresh_token: refreshToken });
// // send token to client
// browserWindow.webContents.send(Channels.AUTH_TOKENS, refreshToken);
// } else {
// const token = await myApiOauth.openAuthWindowAndGetTokens();
// // store the refresh token in cookies for app reopen
// store.set("tokens", token);
// // todo: send the access token to the renderer
// // send token to client
// browserWindow.webContents.send(Channels.AUTH_TOKENS, token);
// }
// FRESH GOOGLE LOGIN...either no json web tokens or trying to sign in with another account.
export async function handleGoogleLogin() {
const tokens = await myApiOauth.openAuthWindowAndGetTokens();
store.set(STORE_ITEMS.AUTH_TOKENS, tokens);
store.set(STORE_ITEMS.GOOGLE_AUTH_TOKENS, tokens);
browserWindow.webContents.send(Channels.AUTH_TOKENS, tokens);
browserWindow.webContents.send(Channels.GOOGLE_AUTH_TOKENS, tokens);
}