Version 3 #67

Merged
danieljsummers merged 53 commits from version-3 into master 2021-10-26 23:39:59 +00:00
8 changed files with 40 additions and 29 deletions
Showing only changes of commit e59472a683 - Show all commits

View File

@ -1 +0,0 @@
[{"tagName":"script","closeTag":true,"attributes":{"type":"text/javascript","src":"/js/chunk-vendors-legacy.fc4b9fd6.js"}},{"tagName":"script","closeTag":true,"attributes":{"type":"text/javascript","src":"/js/app-legacy.7e012dcd.js"}}]

View File

@ -23,6 +23,7 @@
"vuex": "^3.0.1" "vuex": "^3.0.1"
}, },
"devDependencies": { "devDependencies": {
"@types/auth0-js": "^9.10.6",
"@typescript-eslint/eslint-plugin": "^2.8.0", "@typescript-eslint/eslint-plugin": "^2.8.0",
"@typescript-eslint/parser": "^2.8.0", "@typescript-eslint/parser": "^2.8.0",
"@vue/cli-plugin-babel": "^4.0.5", "@vue/cli-plugin-babel": "^4.0.5",

View File

@ -1,7 +1,7 @@
'use strict' 'use strict'
/* eslint-disable */ /* eslint-disable */
import auth0 from 'auth0-js' import auth0 from 'auth0-js'
import EventEmitter from 'events' import { EventEmitter } from 'events'
import AUTH_CONFIG from './auth0-variables' import AUTH_CONFIG from './auth0-variables'
import mutations from '@/store/mutation-types' import mutations from '@/store/mutation-types'
@ -26,7 +26,7 @@ class AuthService extends EventEmitter {
AUTH_SESSION = 'auth-session' AUTH_SESSION = 'auth-session'
// Received and calculated values for our ssesion (initially loaded from local storage if present) // Received and calculated values for our ssesion (initially loaded from local storage if present)
session = {} session: any = {}
constructor() { constructor() {
super() super()
@ -64,7 +64,7 @@ class AuthService extends EventEmitter {
*/ */
async handleAuthentication (store) { async handleAuthentication (store) {
try { try {
const authResult = await this.parseHash() const authResult: any = await this.parseHash()
if (authResult && authResult.accessToken && authResult.idToken) { if (authResult && authResult.accessToken && authResult.idToken) {
this.setSession(authResult) this.setSession(authResult)
store.commit(mutations.USER_LOGGED_ON, this.session.profile) store.commit(mutations.USER_LOGGED_ON, this.session.profile)
@ -102,7 +102,7 @@ class AuthService extends EventEmitter {
refreshSession () { refreshSession () {
this.session = this.session =
localStorage.getItem(this.AUTH_SESSION) localStorage.getItem(this.AUTH_SESSION)
? JSON.parse(localStorage.getItem(this.AUTH_SESSION)) ? JSON.parse(localStorage.getItem(this.AUTH_SESSION) || '{}')
: { profile: {}, : { profile: {},
id: { id: {
token: null, token: null,
@ -182,7 +182,7 @@ class AuthService extends EventEmitter {
return this.session.access.token return this.session.access.token
} else { } else {
try { try {
const authResult = await this.renewTokens() const authResult: any = await this.renewTokens()
return authResult.accessToken return authResult.accessToken
} catch (reject) { } catch (reject) {
throw reject throw reject

View File

@ -21,11 +21,11 @@ import { MdApp,
MdTooltip } from 'vue-material/dist/components' MdTooltip } from 'vue-material/dist/components'
// myPrayerJournal components // myPrayerJournal components
import App from './App' import App from './App.vue'
import router from './router' import router from './router'
import store from './store' import store from './store'
import DateFromNow from './components/common/DateFromNow' import DateFromNow from './components/common/DateFromNow.vue'
import PageTitle from './components/common/PageTitle' import PageTitle from './components/common/PageTitle.vue'
import AuthPlugin from './plugins/auth' import AuthPlugin from './plugins/auth'
/* eslint-enable */ /* eslint-enable */

View File

@ -5,12 +5,12 @@ import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import auth from './auth/AuthService' import auth from './auth/AuthService'
import Home from '@/components/Home' import Home from '@/components/Home.vue'
/* eslint-enable */ /* eslint-enable */
Vue.use(Router) Vue.use(Router)
export default new Router({ const router = new Router({
mode: 'history', mode: 'history',
base: process.env.BASE_URL, base: process.env.BASE_URL,
scrollBehavior (to, from, savedPosition) { scrollBehavior (to, from, savedPosition) {
@ -20,12 +20,6 @@ export default new Router({
return { x: 0, y: 0 } return { x: 0, y: 0 }
} }
}, },
beforeEach (to, from, next) {
if (to.path === '/' || to.path === '/user/log-on' || auth.isAuthenticated()) {
return next()
}
auth.login({ target: to.path })
},
routes: [ routes: [
{ {
path: '/', path: '/',
@ -35,49 +29,58 @@ export default new Router({
{ {
path: '/journal', path: '/journal',
name: 'Journal', name: 'Journal',
component: () => import('@/components/Journal') component: () => import('@/components/Journal.vue')
}, },
{ {
path: '/legal/privacy-policy', path: '/legal/privacy-policy',
name: 'PrivacyPolicy', name: 'PrivacyPolicy',
component: () => import('@/components/legal/PrivacyPolicy') component: () => import('@/components/legal/PrivacyPolicy.vue')
}, },
{ {
path: '/legal/terms-of-service', path: '/legal/terms-of-service',
name: 'TermsOfService', name: 'TermsOfService',
component: () => import('@/components/legal/TermsOfService') component: () => import('@/components/legal/TermsOfService.vue')
}, },
{ {
path: '/request/:id/edit', path: '/request/:id/edit',
name: 'EditRequest', name: 'EditRequest',
component: () => import('@/components/request/EditRequest'), component: () => import('@/components/request/EditRequest.vue'),
props: true props: true
}, },
{ {
path: '/request/:id/full', path: '/request/:id/full',
name: 'FullRequest', name: 'FullRequest',
component: () => import('@/components/request/FullRequest'), component: () => import('@/components/request/FullRequest.vue'),
props: true props: true
}, },
{ {
path: '/requests/active', path: '/requests/active',
name: 'ActiveRequests', name: 'ActiveRequests',
component: () => import('@/components/request/ActiveRequests') component: () => import('@/components/request/ActiveRequests.vue')
}, },
{ {
path: '/requests/answered', path: '/requests/answered',
name: 'AnsweredRequests', name: 'AnsweredRequests',
component: () => import('@/components/request/AnsweredRequests') component: () => import('@/components/request/AnsweredRequests.vue')
}, },
{ {
path: '/requests/snoozed', path: '/requests/snoozed',
name: 'SnoozedRequests', name: 'SnoozedRequests',
component: () => import('@/components/request/SnoozedRequests') component: () => import('@/components/request/SnoozedRequests.vue')
}, },
{ {
path: '/user/log-on', path: '/user/log-on',
name: 'LogOn', name: 'LogOn',
component: () => import('@/components/user/LogOn') component: () => import('@/components/user/LogOn.vue')
} }
] ]
}) })
router.beforeEach((to, from, next) => {
if (to.path === '/' || to.path === '/user/log-on' || auth.isAuthenticated()) {
return next()
}
auth.login({ target: to.path })
})
export default router

View File

@ -61,11 +61,13 @@ const sortValue = x => x.showAfter === 0 ? x.asOf : x.showAfter
*/ */
const journalSort = (a, b) => sortValue(a) - sortValue(b) const journalSort = (a, b) => sortValue(a) - sortValue(b)
const emptyJournal: any = []
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
user: auth.session.profile, user: auth.session.profile,
isAuthenticated: auth.isAuthenticated(), isAuthenticated: auth.isAuthenticated(),
journal: [], journal: emptyJournal,
isLoadingJournal: false isLoadingJournal: false
}, },
mutations: { mutations: {
@ -137,7 +139,7 @@ export default new Vuex.Store({
progress.$emit('show', 'indeterminate') progress.$emit('show', 'indeterminate')
try { try {
await setBearer() await setBearer()
const oldReq = (state.journal.filter(req => req.requestId === requestId) || [])[0] || {} const oldReq: any = (state.journal.filter(req => req.requestId === requestId) || [])[0] || {}
if (!(status === 'Prayed' && updateText === '')) { if (!(status === 'Prayed' && updateText === '')) {
if (status !== 'Answered' && (oldReq.recurType !== recurType || oldReq.recurCount !== recurCount)) { if (status !== 'Answered' && (oldReq.recurType !== recurType || oldReq.recurCount !== recurCount)) {
await api.updateRecurrence(requestId, recurType, recurCount) await api.updateRecurrence(requestId, recurType, recurCount)

View File

@ -9,6 +9,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"sourceMap": true, "sourceMap": true,
"noImplicitAny": false,
"baseUrl": ".", "baseUrl": ".",
"types": [ "types": [
"webpack-env" "webpack-env"

View File

@ -781,6 +781,11 @@
error-stack-parser "^2.0.0" error-stack-parser "^2.0.0"
string-width "^2.0.0" string-width "^2.0.0"
"@types/auth0-js@^9.10.6":
version "9.10.6"
resolved "https://registry.yarnpkg.com/@types/auth0-js/-/auth0-js-9.10.6.tgz#9782ac28ea9cff5a2594b780fd3fd0caa615d1e6"
integrity sha512-tPdhjqzQRJOdILFLssr/zrinjNvYsKKrEzS74XK80ZkQJKejjTERbIh3+T5niFKxx3XYPB3140ys8Y4Q2UFwHw==
"@types/babel-types@*", "@types/babel-types@^7.0.0": "@types/babel-types@*", "@types/babel-types@^7.0.0":
version "7.0.7" version "7.0.7"
resolved "https://registry.yarnpkg.com/@types/babel-types/-/babel-types-7.0.7.tgz#667eb1640e8039436028055737d2b9986ee336e3" resolved "https://registry.yarnpkg.com/@types/babel-types/-/babel-types-7.0.7.tgz#667eb1640e8039436028055737d2b9986ee336e3"