@afeefa/vue-app 0.0.108 → 0.0.109

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 0.0.108
1
+ 0.0.109
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.108",
3
+ "version": "0.0.109",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -2,7 +2,7 @@ import './config/event-bus'
2
2
  import './config/components'
3
3
  import './directives'
4
4
 
5
- import { hasRightsPlugin } from '@a-admin/plugins/translation/HasRightsPlugin'
5
+ import { authPlugin } from '@a-admin/plugins/AuthPlugin'
6
6
  import { translationPlugin } from '@a-admin/plugins/translation/TranslationPlugin'
7
7
  import { apiResourcesPlugin } from '@a-vue/plugins/api-resources/ApiResourcesPlugin'
8
8
  import { hasOptionsPlugin } from '@a-vue/plugins/has-options/HasOptionsPlugin'
@@ -20,12 +20,18 @@ Vue.use(translationPlugin)
20
20
  Vue.config.productionTip = false
21
21
 
22
22
  export async function bootstrap ({ apis, models, routing, authService, getTranslations, app, components }) {
23
- apiResourcesPlugin.register(models, apis)
24
-
25
23
  appConfig.authService = authService
26
24
  appConfig.app = app
27
25
  appConfig.components = components
28
26
 
27
+ if (authService) {
28
+ const authenticated = await authService.authenticate()
29
+ if (!authenticated) {
30
+ return
31
+ }
32
+ Vue.use(authPlugin)
33
+ }
34
+
29
35
  const splash = new Vue({
30
36
  vuetify,
31
37
  el: '#splash',
@@ -35,8 +41,15 @@ export async function bootstrap ({ apis, models, routing, authService, getTransl
35
41
  }
36
42
  })
37
43
 
44
+ if (authService) {
45
+ await authService.init()
46
+ }
47
+
48
+ apiResourcesPlugin.register(models, apis)
49
+
38
50
  routing(routeConfigPlugin)
39
51
  const router = await routeConfigPlugin.getRouter()
52
+
40
53
  await apiResourcesPlugin.schemasLoaded()
41
54
 
42
55
  if (getTranslations) {
@@ -44,12 +57,6 @@ export async function bootstrap ({ apis, models, routing, authService, getTransl
44
57
  translationPlugin.setTranslations(translations.models)
45
58
  }
46
59
 
47
- if (authService) {
48
- Vue.use(hasRightsPlugin)
49
-
50
- authService.initApp(router)
51
- }
52
-
53
60
  // routeConfigPlugin.dumpRoutes()
54
61
  // routeConfigPlugin.dumbBreadcrumbs()
55
62
 
@@ -143,16 +143,10 @@ import '../styles.scss'
143
143
  export default class App extends Vue {
144
144
  drawer = true
145
145
  isLoading = false
146
- account = null
147
146
 
148
147
  created () {
149
148
  this.$events.on(LoadingEvent.START_LOADING, this.startLoading)
150
149
  this.$events.on(LoadingEvent.STOP_LOADING, this.stopLoading)
151
-
152
- if (this.hasAuthService) {
153
- this.account = appConfig.authService.getAccount()
154
- }
155
-
156
150
  this.$emit('appLoaded')
157
151
  }
158
152
 
@@ -164,6 +158,13 @@ export default class App extends Vue {
164
158
  return appConfig.app.logo
165
159
  }
166
160
 
161
+ get account () {
162
+ if (this.hasAuthService) {
163
+ return this.$auth.account
164
+ }
165
+ return null
166
+ }
167
+
167
168
  get title () {
168
169
  return appConfig.app.title
169
170
  }
@@ -189,11 +190,11 @@ export default class App extends Vue {
189
190
  }
190
191
 
191
192
  get hasAuthService () {
192
- return !!appConfig.authService
193
+ return !!this.$auth
193
194
  }
194
195
 
195
196
  logout () {
196
- appConfig.authService.forwardToLogoutEndpoint()
197
+ this.$auth.logout()
197
198
  }
198
199
  }
199
200
  </script>
@@ -1,4 +1,4 @@
1
- import { Component, Watch, Vue } from '@a-vue'
1
+ import { Component, Vue, Watch } from '@a-vue'
2
2
 
3
3
  Component.registerHooks([
4
4
  'beforeRouteEnter',
@@ -50,7 +50,7 @@ export class DataRouteMixin extends Vue {
50
50
 
51
51
  // watches (if defined) route idKey and reloads data if changed
52
52
  @Watch('drm_id')
53
- async routeParamsChanged () {
53
+ async drm_routeParamsChanged () {
54
54
  if (routerHookCalled) {
55
55
  return
56
56
  }
@@ -0,0 +1,21 @@
1
+ import { appConfig } from '../config/AppConfig'
2
+
3
+ class AuthPlugin {
4
+ install (Vue) {
5
+ const authService = appConfig.authService
6
+ const $auth = {
7
+ account: authService.getCurrentAccount(),
8
+
9
+ hasRight: name => authService.currentAccountHasRight(name),
10
+
11
+ hasRole: name => authService.currentAccountHasRole(name),
12
+
13
+ logout: () => authService.forwardToLogoutEndpoint()
14
+ }
15
+
16
+ Vue.prototype.$auth = $auth
17
+ Vue.$auth = $auth
18
+ }
19
+ }
20
+
21
+ export const authPlugin = new AuthPlugin()
@@ -1,15 +0,0 @@
1
- import { authService } from '@k-vue/auth/AuthService'
2
-
3
- class HasRightsPlugin {
4
- install (Vue) {
5
- Vue.mixin({
6
- created () {
7
- this.$hasRight = name => {
8
- return authService.currentAccountHasRight(name)
9
- }
10
- }
11
- })
12
- }
13
- }
14
-
15
- export const hasRightsPlugin = new HasRightsPlugin()