default.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <!-- Don't drop "q-app" class -->
  3. <div id="q-app">
  4. <router-view />
  5. </div>
  6. </template>
  7. <script>
  8. /*
  9. * Root component
  10. */
  11. var db = require('../db.js')
  12. var utils = require('../utils.js')
  13. var api = require('../api.js')
  14. export default {
  15. methods: {
  16. redirect_if_not_logged: function (){
  17. if (this.$route.name == 'login' ||
  18. this.$route.name == 'oauth_redirect' ||
  19. this.$route.name == 'register' ) {
  20. return true
  21. }
  22. var self = this
  23. db.getToken()
  24. .then(data => {
  25. if (data.token.length < 4){
  26. self.$router.push('login')
  27. self.$q.notify('You must login to access this page')
  28. }
  29. })
  30. .catch(() => {
  31. self.$router.push('login')
  32. self.$q.notify('You must login to access this page')
  33. })
  34. }
  35. },
  36. beforeCreate: function () {
  37. window.me = this
  38. window.api = api
  39. window.db = db
  40. // check if the user is logged in, if not goto login page
  41. },
  42. mounted: function () {
  43. api.setCurrentPage(this)
  44. this.redirect_if_not_logged()
  45. },
  46. framework: {
  47. i18n: 'de'
  48. }
  49. }
  50. </script>
  51. <style></style>