From 4fce076ee5671e046410d44d4d0492478ea8fc6a Mon Sep 17 00:00:00 2001
From: "Daniel J. Summers"
Date: Wed, 21 Jul 2021 23:04:11 -0400
Subject: [PATCH] WIP on login from NAS
---
src/JobsJobsJobs/App/src/App.vue | 2 +-
src/JobsJobsJobs/App/src/api/index.ts | 25 ++++++++++++
src/JobsJobsJobs/App/src/api/types.ts | 10 +++++
.../App/src/components/shared/AppFooter.vue | 14 -------
.../App/src/components/shared/AppNav.vue | 17 +++++++--
.../App/src/components/shared/AudioClip.vue | 20 ++++++----
src/JobsJobsJobs/App/src/main.ts | 4 +-
src/JobsJobsJobs/App/src/router/index.ts | 26 ++++---------
src/JobsJobsJobs/App/src/store/index.ts | 38 ++++++++++++++++++-
.../App/src/views/citizen/Authorized.vue | 34 +++++++++++++++++
10 files changed, 141 insertions(+), 49 deletions(-)
create mode 100644 src/JobsJobsJobs/App/src/api/index.ts
create mode 100644 src/JobsJobsJobs/App/src/api/types.ts
create mode 100644 src/JobsJobsJobs/App/src/views/citizen/Authorized.vue
diff --git a/src/JobsJobsJobs/App/src/App.vue b/src/JobsJobsJobs/App/src/App.vue
index d5f4406..699f5c5 100644
--- a/src/JobsJobsJobs/App/src/App.vue
+++ b/src/JobsJobsJobs/App/src/App.vue
@@ -30,7 +30,7 @@ export default defineComponent({
AppNav,
TitleBar
},
- data () {
+ setup () {
return {
//
}
diff --git a/src/JobsJobsJobs/App/src/api/index.ts b/src/JobsJobsJobs/App/src/api/index.ts
new file mode 100644
index 0000000..e81ce88
--- /dev/null
+++ b/src/JobsJobsJobs/App/src/api/index.ts
@@ -0,0 +1,25 @@
+import { LogOnSuccess } from './types'
+
+/**
+ * Create a URL that will access the API
+ * @param url The partial URL for the API
+ * @returns A full URL for the API
+ */
+const apiUrl = (url : string) : string => `/api/${url}`
+
+export default {
+
+ /**
+ * Log a citizen on
+ * @param code The authorization code from No Agenda Social
+ * @returns The user result, or an error
+ */
+ logOn: async (code : string) : Promise => {
+ const resp = await fetch(apiUrl(`/citizen/log-on/${code}`), { method: 'GET' })
+ if (resp.status === 200) return await resp.json() as LogOnSuccess
+ console.error(await resp.text())
+ return 'Error logging on'
+ }
+}
+
+export * from './types'
diff --git a/src/JobsJobsJobs/App/src/api/types.ts b/src/JobsJobsJobs/App/src/api/types.ts
new file mode 100644
index 0000000..34bfb0e
--- /dev/null
+++ b/src/JobsJobsJobs/App/src/api/types.ts
@@ -0,0 +1,10 @@
+
+/** A successful logon */
+export interface LogOnSuccess {
+ /** The JSON Web Token (JWT) to use for API access */
+ jwt : string
+ /** The ID of the logged-in citizen (as a string) */
+ citizenId : string
+ /** The name of the logged-in citizen */
+ name : string
+}
diff --git a/src/JobsJobsJobs/App/src/components/shared/AppFooter.vue b/src/JobsJobsJobs/App/src/components/shared/AppFooter.vue
index a6cd928..92a4bae 100644
--- a/src/JobsJobsJobs/App/src/components/shared/AppFooter.vue
+++ b/src/JobsJobsJobs/App/src/components/shared/AppFooter.vue
@@ -4,20 +4,6 @@
-
-