setting up api more nad getting closer to the connection to backend and adding auth middleware almost

This commit is contained in:
talksik
2022-03-15 16:16:31 -04:00
parent e9a02eb091
commit 565b01cd8e
8 changed files with 52 additions and 25 deletions
+3 -3
View File
@@ -83,7 +83,7 @@ app.on("activate", () => {
async function handleLogin() {
// read saved refresh token if any
// todo: fix this...should be working
const refreshToken = await store.get("refresh_token");
const refreshToken = await store.get("tokens");
// todo: remove this when I have way of getting access token from a refresh token
if (refreshToken && false) {
@@ -96,10 +96,10 @@ async function handleLogin() {
const token = await myApiOauth.openAuthWindowAndGetTokens();
// store the refresh token in cookies for app reopen
store.set("refresh_token", token.refresh_token);
store.set("tokens", token);
// todo: send the access token to the renderer
// send token to client
win.webContents.send(channels.AUTH_TOKEN, token.access_token);
win.webContents.send(channels.AUTH_TOKENS, token);
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ export default function Login() {
};
useEffect(() => {
window.API.receive(channels.AUTH_TOKEN, async (accessToken: string) => {
window.API.receive(channels.AUTH_TOKENS, async (accessToken: string) => {
console.log(accessToken);
// get user info from access token
+1 -1
View File
@@ -1,6 +1,6 @@
module.exports = {
channels: {
ACTIVATE_LOG_IN: "ACTIVATE_LOG_IN",
AUTH_TOKEN: "AUTH_TOKEN",
AUTH_TOKENS: "AUTH_TOKENS",
},
};