setting up api more nad getting closer to the connection to backend and adding auth middleware almost
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,6 +1,6 @@
|
||||
module.exports = {
|
||||
channels: {
|
||||
ACTIVATE_LOG_IN: "ACTIVATE_LOG_IN",
|
||||
AUTH_TOKEN: "AUTH_TOKEN",
|
||||
AUTH_TOKENS: "AUTH_TOKENS",
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user