changing folder name
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
enum Channels {
|
||||
ACTIVATE_LOG_IN = "ACTIVATE_LOG_IN",
|
||||
AUTH_TOKENS = "AUTH_TOKENS",
|
||||
}
|
||||
|
||||
export default Channels;
|
||||
@@ -0,0 +1,41 @@
|
||||
import Channels from "./constants";
|
||||
import ElectronGoogleOAuth2 from "@getstation/electron-google-oauth2";
|
||||
import { browserWindow } from "../index";
|
||||
import { ipcMain } from "electron";
|
||||
import store from "./store";
|
||||
|
||||
const myApiOauth = new ElectronGoogleOAuth2(
|
||||
"423533244953-banligobgbof8hg89i6cr1l7u0p7c2pk.apps.googleusercontent.com",
|
||||
"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",
|
||||
[""],
|
||||
{ successRedirectURL: "https://usenirvana.com" }
|
||||
);
|
||||
|
||||
export async function handleLogin() {
|
||||
// read saved refresh token if any
|
||||
// todo: fix this...should be working
|
||||
const refreshToken = await store.get("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);
|
||||
// }
|
||||
|
||||
const tokens = await myApiOauth.openAuthWindowAndGetTokens();
|
||||
store.set("tokens", tokens);
|
||||
|
||||
browserWindow.webContents.send(Channels.AUTH_TOKENS, tokens);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import Store from "electron-store";
|
||||
const store = new Store();
|
||||
|
||||
export default store;
|
||||
Reference in New Issue
Block a user