Skip to content

Commit

Permalink
Fix Login redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeon Vinzenz Varapragasam authored and Yeon Vinzenz Varapragasam committed Jan 29, 2024
1 parent c045934 commit 1c95e41
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
7 changes: 6 additions & 1 deletion public/app/handlers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, shell } = require('electron')
const { app, shell, BrowserWindow } = require('electron')
const path = require('path')
const { generateMfaQr, handleVerifyOTP } = require('./otp.js')
const { coreParams, isCC, defaultCoreParams, store } = require('./core.js')
Expand All @@ -12,6 +12,11 @@ const handlers = async (wind, subprocesses, event, parameters) => {
case 'verify_otp':
handleVerifyOTP(event, parameters)
break
case 'get-all-windows':
const allWIndows = BrowserWindow.getAllWindows()
console.log('allWIndows', allWIndows)
wind.webContents.send('fromMain', ['all-windows', allWIndows])
break
case 'generate-mfa-qr':
generateMfaQr(event, parameters)
break
Expand Down
7 changes: 5 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export default function App() {
'padding: 3px 5px; border-radius: 5px; color: #ffffff; background-color: #038fc7;'
)
if (isElectron()) {
;(window as any).api.send('toMain', { command: 'get-platform' })
;(window as any).api.send('toMain', { command: 'get-core-params' })
;(window as any)?.api?.send('toMain', { command: 'get-platform' })
;(window as any)?.api?.send('toMain', { command: 'get-core-params' })
}
}, [])
;(window as any).api?.receive('fromMain', (parameters: any) => {
Expand Down Expand Up @@ -109,6 +109,9 @@ export default function App() {
if (parameters === 'clear-frontend') {
deleteFrontendConfig()
}
if (parameters === 'all-windows') {
console.log('all-windows', parameters[1])
}
})

useEffect(() => {
Expand Down
7 changes: 5 additions & 2 deletions src/components/Bars/BarTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const TopBar = () => {
const updateNotificationInterval = useStore(
(state) => state.updateNotificationInterval
)

const isCreator = localStorage.getItem('ledfx-cloud-role') === 'creator'
const invisible = () => {
switch (pathname.split('/')[1]) {
case 'device':
Expand Down Expand Up @@ -431,7 +431,7 @@ const TopBar = () => {
</ListItemIcon>
Change Host
</MenuItem>
{isCC && (
{isCC && isCreator && (
<MenuItem onClick={changeHostManager}>
<ListItemIcon>
<Lan />
Expand Down Expand Up @@ -484,6 +484,9 @@ const TopBar = () => {
'_blank',
'noopener,noreferrer'
)
setTimeout(() => {
window.location.reload()
}, 5000)
}
}}
>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/Login/LoginRedirect.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react'
import { useNavigate, useLocation, useParams } from 'react-router-dom'
import axios from 'axios'
import isElectron from 'is-electron'

const cloud = axios.create({
baseURL: 'https://strapi.yeonv.com'
Expand Down Expand Up @@ -46,7 +47,9 @@ const LoginRedirect = () => {
'username'
)}. You will be redirected in a few seconds...`
)
setTimeout(() => history('/devices'), 2000) // Redirect to homepage after 3 sec
setTimeout(() => {
return isElectron() ? window.close() : history('/devices')
}, 2000)
})
.catch((err) => {
// eslint-disable-next-line no-console
Expand Down

0 comments on commit 1c95e41

Please sign in to comment.