Skip to content

Commit a963047

Browse files
authored
Merge pull request #361 from lockdown-systems/358-manage-in-browser
Manage accounts in browser
2 parents 0c4a3d7 + 5f2c5d0 commit a963047

File tree

4 files changed

+53
-186
lines changed

4 files changed

+53
-186
lines changed

src/renderer/src/views/ManageAccountView.vue

Lines changed: 0 additions & 127 deletions
This file was deleted.

src/renderer/src/views/TabsView.vue

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import AccountView from './AccountView.vue';
55
import CydAPIClient from '../../../cyd-api-client';
66
import type { DeviceInfo } from '../types';
77
import type { Account } from '../../../shared_types';
8-
import ManageAccountView from './ManageAccountView.vue';
98
import AboutView from './AboutView.vue';
9+
import { openURL } from '../util';
1010
1111
// Get the global emitter
1212
const vueInstance = getCurrentInstance();
@@ -24,12 +24,10 @@ const refreshDeviceInfo = inject('refreshDeviceInfo') as () => Promise<void>;
2424
const refreshAPIClient = inject('refreshAPIClient') as () => Promise<void>;
2525
2626
const hideAllAccounts = ref(false);
27-
const showManageAccount = ref(false);
2827
2928
const showAbout = ref(false);
3029
3130
const accountClicked = async (account: Account) => {
32-
hideManageAccountView();
3331
hideAboutView();
3432
3533
activeAccountID.value = account.id;
@@ -48,7 +46,6 @@ const accountClicked = async (account: Account) => {
4846
};
4947
5048
const addAccountClicked = async () => {
51-
hideManageAccountView();
5249
hideAboutView();
5350
5451
// Do we already have an unknown account?
@@ -91,7 +88,6 @@ const removeAccount = async (accountID: number) => {
9188
}
9289
9390
const accountSelected = async (account: Account, accountType: string) => {
94-
hideManageAccountView();
9591
hideAboutView();
9692
9793
try {
@@ -131,44 +127,27 @@ const outsideUserMenuClicked = (event: MouseEvent) => {
131127
}
132128
};
133129
134-
const showManageAccountView = () => {
130+
const openDashboard = async () => {
135131
userBtnShowMenu.value = false;
136132
137-
showManageAccount.value = true;
138-
showAbout.value = false;
139-
hideAllAccounts.value = true;
140-
};
141-
142-
const hideManageAccountView = () => {
143-
showManageAccount.value = false;
144-
showAbout.value = false;
145-
hideAllAccounts.value = false;
133+
const dashURL = await window.electron.getDashURL();
134+
const nativeLoginURL = `${dashURL}/#/native-login/${deviceInfo.value?.userEmail}/${deviceInfo.value?.deviceToken}/manage`;
135+
openURL(nativeLoginURL);
146136
};
147137
148-
emitter?.on('show-manage-account', showManageAccountView);
138+
emitter?.on('show-manage-account', openDashboard);
149139
150140
const manageAccountClicked = async () => {
151-
localStorage.setItem('manageAccountMode', 'manage');
152-
showManageAccountView();
153-
};
154-
155-
const redirectToAccount = (accountID: number) => {
156-
// This forces the account to re-check if the user is signed in and if premium is enabled
157-
emitter?.emit('signed-in');
158-
159-
activeAccountID.value = accountID;
160-
hideManageAccountView();
141+
openDashboard();
161142
};
162143
163144
const showAboutView = () => {
164145
userBtnShowMenu.value = false;
165-
showManageAccount.value = false;
166146
showAbout.value = true;
167147
hideAllAccounts.value = true;
168148
};
169149
170150
const hideAboutView = () => {
171-
showManageAccount.value = false;
172151
showAbout.value = false;
173152
hideAllAccounts.value = false;
174153
};
@@ -178,7 +157,6 @@ const aboutClicked = async () => {
178157
};
179158
180159
const signInClicked = async () => {
181-
localStorage.setItem('manageAccountMode', 'manage');
182160
emitter?.emit('show-sign-in');
183161
};
184162
@@ -207,12 +185,9 @@ const signOutClicked = async () => {
207185
await refreshDeviceInfo();
208186
await refreshAPIClient();
209187
210-
showManageAccount.value = false;
211188
userBtnShowMenu.value = false;
212189
213190
emitter?.emit('signed-out');
214-
215-
hideManageAccountView();
216191
};
217192
218193
const checkForUpdatesClicked = async () => {
@@ -242,7 +217,7 @@ onMounted(async () => {
242217
document.addEventListener('click', outsideUserMenuClicked);
243218
document.addEventListener('auxclick', outsideUserMenuClicked);
244219
245-
emitter?.on('signed-in', showManageAccountView);
220+
emitter?.on('signed-in', openDashboard);
246221
emitter?.on('account-updated', reloadAccounts);
247222
});
248223
@@ -339,9 +314,6 @@ onUnmounted(async () => {
339314
:class="{ 'hide': hideAllAccounts || activeAccountID !== account.id }" @account-selected="accountSelected"
340315
@on-remove-clicked="removeAccount(account.id)" />
341316

342-
<!-- Manay my Cyd account -->
343-
<ManageAccountView :should-show="showManageAccount" @redirect-to-account="redirectToAccount" />
344-
345317
<!-- About -->
346318
<AboutView :should-show="showAbout" />
347319
</div>

src/renderer/src/views/x/AccountXView.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,17 @@ const updateUserPremium = async () => {
219219
return;
220220
}
221221
userPremium.value = userPremiumResp.premium_access;
222+
223+
if (!userPremium.value) {
224+
console.log('User does not have Premium access');
225+
emitter?.emit(`x-premium-check-failed-${props.account.id}`);
226+
}
222227
};
223228
224229
emitter?.on('signed-in', async () => {
225230
console.log('AccountXView: User signed in');
226231
await updateUserAuthenticated();
227232
await updateUserPremium();
228-
if (!userPremium.value) {
229-
emitter?.emit('show-manage-account');
230-
}
231233
});
232234
233235
emitter?.on('signed-out', async () => {
@@ -480,7 +482,7 @@ onUnmounted(async () => {
480482
<XWizardCheckPremium v-if="model.state == State.WizardCheckPremiumDisplay" :model="unref(model)"
481483
:user-authenticated="userAuthenticated" :user-premium="userPremium"
482484
@set-state="setState($event)" @update-account="updateAccount"
483-
@start-jobs-just-save="startJobsJustSave" />
485+
@start-jobs-just-save="startJobsJustSave" @update-user-premium="updateUserPremium" />
484486

485487
<XFinishedRunningJobsPage v-if="model.state == State.FinishedRunningJobsDisplay"
486488
:model="unref(model)"

0 commit comments

Comments
 (0)