-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00e2ad0
commit 97c7c88
Showing
6 changed files
with
136 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 75 additions & 63 deletions
138
resources/src/models/auth/components/OrcidCallbackCard.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,84 @@ | ||
<template> | ||
<q-card> | ||
<q-card-section class="flex flex-center column"> | ||
<template v-if="loading"> | ||
<h5>{{ $t('orcid.verifying') }}</h5> | ||
<q-spinner-dots size="50px" color="primary" /> | ||
</template> | ||
<template v-else-if="valid"> | ||
<q-icon | ||
name="mdi-check-decagram-outline" | ||
size="50px" | ||
color="primary" | ||
class="q-mb-md" | ||
/> | ||
<h5 class="q-my-none text-center"> | ||
{{ $t('orcid.verified-with') }} | ||
</h5> | ||
|
||
<h6 class="q-mt-md">{{ author?.orcid }}</h6> | ||
<q-btn | ||
label="Continue" | ||
color="primary" | ||
@click=" | ||
$router.push({ | ||
name: 'settings.author', | ||
}) | ||
" | ||
/> | ||
</template> | ||
<template v-else> | ||
<q-icon name="error" size="50px" color="red" /> | ||
<h5>{{ $t('orcid.error-verifying') }}</h5> | ||
</template> | ||
</q-card-section> | ||
</q-card> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Author, AuthorService } from '@/models/Author/Author'; | ||
import type { Author } from '@/models/Author/Author' | ||
import { AuthorService } from '@/models/Author/Author' | ||
const router = useRouter() | ||
const authStore = useAuthStore() | ||
const { t } = useI18n() | ||
const router = useRouter(); | ||
const authStore = useAuthStore(); | ||
type statuses = 'success' | 'invalid-key' | 'invalid-user' | 'failed' | undefined | ||
const status = ref((router.currentRoute.value.query?.status as statuses) || undefined) | ||
const code = ref((router.currentRoute.value.query?.code as string) || ''); | ||
const loading = ref(true) | ||
const valid = computed(() => status.value === 'success') | ||
const loading = ref(true); | ||
const valid = ref(false); | ||
const author = ref<Author | null>(null); | ||
const errorMessage = computed(() => { | ||
switch (status.value) { | ||
case 'invalid-key': | ||
return t('orcid.invalid-key') | ||
case 'invalid-user': | ||
return t('orcid.invalid-user') | ||
case 'failed': | ||
case undefined: | ||
return t('orcid.failed') | ||
default: | ||
return '' | ||
} | ||
}) | ||
async function verifyWithBackend() { | ||
AuthorService.verifyOrcid(code.value) | ||
.then((response) => { | ||
console.log(response); | ||
valid.value = true; | ||
author.value = response.data; | ||
authStore.refreshUser(true); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}) | ||
.finally(() => { | ||
loading.value = false; | ||
}); | ||
} | ||
const author = ref<Author | null>(null) | ||
onMounted(() => { | ||
console.log('mounted'); | ||
verifyWithBackend(); | ||
}); | ||
onMounted(async () => { | ||
if (status.value === 'success') { | ||
if (!authStore.user?.authorId) { | ||
status.value = undefined | ||
return | ||
} | ||
const { data } = await AuthorService.find(authStore.user.authorId) | ||
author.value = data | ||
} | ||
loading.value = false | ||
}) | ||
</script> | ||
|
||
<template> | ||
<q-card bordered flat class="bg-teal-1"> | ||
<q-card-section class="flex flex-center column"> | ||
<template v-if="loading"> | ||
<h5>{{ $t('orcid.verifying') }}</h5> | ||
<q-spinner-dots size="50px" color="primary" /> | ||
</template> | ||
<template v-else-if="valid"> | ||
<q-icon | ||
name="mdi-check-decagram-outline" | ||
size="50px" | ||
color="primary" | ||
class="q-mb-md" | ||
/> | ||
<h5 class="q-my-none text-center"> | ||
{{ $t('orcid.verified-with') }} | ||
</h5> | ||
|
||
<h6 class="q-mt-md"> | ||
{{ author?.orcid }} | ||
</h6> | ||
<q-btn | ||
label="Continue" | ||
color="primary" | ||
@click=" | ||
router.push({ | ||
name: 'settings.author', | ||
}) | ||
" | ||
/> | ||
</template> | ||
<template v-else> | ||
<q-icon name="error" size="50px" color="red" /> | ||
<h5>{{ t('orcid.error-verifying') }}</h5> | ||
<p>{{ errorMessage }}</p> | ||
</template> | ||
</q-card-section> | ||
</q-card> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters