Tweaks to login flow (#1)
This commit is contained in:
parent
6d16bef137
commit
daece3eab1
@ -40,7 +40,7 @@ export function authorize() {
|
||||
*
|
||||
* @param authCode The authorization code obtained from No Agenda Social
|
||||
*/
|
||||
export async function logOn(authCode: string) {
|
||||
export async function logOn(authCode: string): Promise<string> {
|
||||
try {
|
||||
const resp = await doRequest(`${NAS_URL}oauth/token`, 'POST',
|
||||
JSON.stringify({
|
||||
@ -54,10 +54,8 @@ export async function logOn(authCode: string) {
|
||||
)
|
||||
const token = await resp.json()
|
||||
await jjjAuthorize(token.access_token)
|
||||
// TODO: navigate to user welcome page
|
||||
console.info(`Success - response ${JSON.stringify(token)}`)
|
||||
return ''
|
||||
} catch (e) {
|
||||
// TODO: notify the user
|
||||
console.error(`Failure - ${e}`)
|
||||
return `${e}`
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
|
||||
|
||||
import Home from '../views/Home.vue'
|
||||
import Welcome from '../views/citizen/Welcome.vue'
|
||||
import Authorized from '../views/user/Authorized.vue'
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
@ -22,6 +23,11 @@ const routes: Array<RouteRecordRaw> = [
|
||||
name: 'Authorized',
|
||||
component: Authorized,
|
||||
props: (route) => ({ code: route.query.code })
|
||||
},
|
||||
{
|
||||
path: '/citizen/welcome',
|
||||
name: 'Welcome',
|
||||
component: Welcome
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
<template>
|
||||
<p>Logging you on with No Agenda Social...</p>
|
||||
<p>{{message}}</p>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { logOn } from '@/auth'
|
||||
|
||||
export default {
|
||||
@ -11,8 +12,19 @@ export default {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
logOn(props.code)
|
||||
setup() {
|
||||
const message = ref('Logging you on with No Agenda Social...')
|
||||
return {
|
||||
message
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
const result = await logOn(this.code)
|
||||
if (result === '') {
|
||||
this.$router.push('/citizen/welcome')
|
||||
} else {
|
||||
this.message = `Unable to log on via No Agenda Social:\n${result}`
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user