Skip to content

Commit b3ead0c

Browse files
committed
another try at guest users
1 parent 93eb14d commit b3ead0c

3 files changed

Lines changed: 17 additions & 20 deletions

File tree

src/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import { computed, onMounted } from 'vue';
4646
4747
const globalStore = useGlobalStore();
4848
const route = useRoute();
49-
const isLogin = computed(() => route.name === "login");
5049
5150
onMounted(async () => {
5251
await globalStore.getUserId();

src/stores/globalStore.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,22 @@ export const useGlobalStore = defineStore('globalStore', () => {
2525
}
2626
catch {
2727
currentUser.value = null;
28-
await router.push({ name: "login" });
28+
//await router.push({ name: "login" });
2929
return false;
3030
}
3131

3232
};
3333

3434
async function getUserId() {
35-
return new Promise<string|null>(async (resolve) => {
36-
try {
37-
const { username, userId, signInDetails } = await getCurrentUser();
38-
currentUser.value = userId;
39-
resolve(userId);
40-
}
41-
catch {
42-
43-
currentUser.value = null;
44-
resolve(null);
45-
46-
}
47-
});
35+
try {
36+
const { username, userId, signInDetails } = await getCurrentUser();
37+
currentUser.value = userId;
38+
return userId;
39+
}
40+
catch {
41+
currentUser.value = null;
42+
return null;
43+
}
4844
}
4945

5046
async function signOffUser() {

src/views/HomeView.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ import { getProfessions } from '@/services/lookupTableService';
2929
import { VueShowdown } from 'vue-showdown';
3030
import { onMounted, ref } from 'vue';
3131
import { useGlobalStore } from '@/stores/globalStore';
32+
import { useAuthenticator } from '@aws-amplify/ui-vue';
3233
3334
const router = useRouter();
3435
const professionList = ref();
3536
const globalStore = useGlobalStore();
37+
const auth = useAuthenticator();
3638
3739
const getProfessionList = async () => {
3840
const list = await getProfessions();
@@ -41,12 +43,12 @@ const getProfessionList = async () => {
4143
4244
onMounted(async () => {
4345
const isAuthenticated = await globalStore.isAuthenticated();
44-
if (!isAuthenticated) {
45-
await router.push({name: "login"});
46-
}
47-
else {
46+
// if (!isAuthenticated) {
47+
// await router.push({name: "login"});
48+
// }
49+
// else {
4850
getProfessionList();
49-
}
51+
// }
5052
})
5153
5254
async function createCharacter(profession: string) {

0 commit comments

Comments
 (0)