@metano/quasar_rest_auth 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/.gitattributes +17 -0
  2. package/LICENSE +21 -0
  3. package/Makefile +18 -0
  4. package/README.md +6 -0
  5. package/boot/alerts.js +152 -0
  6. package/boot/api.js +155 -0
  7. package/boot/app.js +111 -0
  8. package/boot/base.js +242 -0
  9. package/boot/config.js +117 -0
  10. package/boot/cripto.js +35 -0
  11. package/boot/data.js +28 -0
  12. package/boot/storage.js +74 -0
  13. package/components/DefinicoesLayout.vue +34 -0
  14. package/components/FormLogin.vue +217 -0
  15. package/components/LeftMenu.vue +93 -0
  16. package/components/LeftMenuSegundo.vue +96 -0
  17. package/components/MyTest.vue +41 -0
  18. package/components/RightMenu.vue +36 -0
  19. package/components/SearchMenu.vue +88 -0
  20. package/components/SettingsLayout.vue +34 -0
  21. package/components/TopMenu.vue +68 -0
  22. package/components/TopMenuSegundo.vue +85 -0
  23. package/components/footer/Comments.vue +77 -0
  24. package/components/footer/MainFooter.vue +71 -0
  25. package/components/header/HeaderBrand.vue +64 -0
  26. package/components/header/HeaderDarkModeToggle.vue +40 -0
  27. package/components/header/HeaderFullScreen.vue +55 -0
  28. package/components/header/HeaderLanguage.vue +56 -0
  29. package/components/header/HeaderNotifications.vue +53 -0
  30. package/components/header/HeaderServices.vue +118 -0
  31. package/components/header/HeaderUser.vue +210 -0
  32. package/components/header/HeaderUserMenu.vue +0 -0
  33. package/components/header/RegistarEntidade.vue +309 -0
  34. package/gitignore +3 -0
  35. package/help +9 -0
  36. package/index.js +9 -0
  37. package/layouts/AuthLayout.vue +74 -0
  38. package/layouts/MainLayout.vue +190 -0
  39. package/package.json +31 -0
  40. package/pages/auth/LoginPage.vue +32 -0
  41. package/pages/routes.js +33 -0
  42. package/stores/AuthStore.js +587 -0
  43. package/stores/example-store.js +21 -0
  44. package/stores/index.js +20 -0
  45. package/stores/settings.js +12 -0
package/boot/base.js ADDED
@@ -0,0 +1,242 @@
1
+
2
+ let result = false
3
+ export const localStorageSetItem = (key, value) => {
4
+ Object.keys(localStorage).forEach(function (keyLocal) {
5
+ if (key === decrypt(keyLocal)) {
6
+ localStorage.removeItem(keyLocal)
7
+ }
8
+ })
9
+ localStorage.setItem(encrypt(key), (value))
10
+ }
11
+
12
+
13
+ export const IsAuthorized = {
14
+ bind (el, binding, vnode) {
15
+ const store = vnode.context.$store
16
+ const permissions = store.getters['auth/getPermissions']
17
+
18
+ permissions.forEach(element => {
19
+ if (element.nome === binding.value) {
20
+ result = true
21
+ }
22
+ })
23
+
24
+ if (!result) {
25
+ el.style.display = 'none'
26
+ }
27
+ }
28
+ }
29
+
30
+ export const pegaDominio = function () {
31
+ let pagelocalurl = location.href // pega endereço que esta no navegador
32
+ pagelocalurl = pagelocalurl.split('/') // quebra o endeço de acordo com a / (barra)
33
+ const dominiourl = pagelocalurl[0] + '//' + pagelocalurl[2]
34
+ return dominiourl // retorna a parte www.endereco.com.brs@
35
+ }
36
+
37
+ export const MeIsAuthorized = function (permissions, permission) {
38
+ let result = false
39
+ // permissions.forEach(element => {
40
+ // if (element.nome === permission) {
41
+ // result = true
42
+ // }
43
+ // })
44
+ result = true
45
+ return result
46
+ }
47
+
48
+ export const traducao = function (texto = '') {
49
+ let returne = ''
50
+ try {
51
+ if (this.$store?.state?.lingua?.Traducao !== '') {
52
+ for (const txt in this.$store?.state?.lingua?.Traducao) {
53
+ for (const key in this.$store?.state?.lingua?.Traducao[txt]) {
54
+ if (remocao(key) === remocao(texto)) {
55
+ const traducao = this.$store?.state?.lingua?.Traducao[txt][key]
56
+ returne = replaceTraducao(texto, traducao)
57
+ }
58
+ }
59
+ }
60
+ }
61
+ } catch (error) {
62
+
63
+ }
64
+ if (returne === '') {
65
+ returne = texto
66
+ }
67
+ return returne
68
+ }
69
+
70
+ function remocao (texto) {
71
+ const re = /(\s*%-\s*[a-zA-Z-0-9\s*]+\s*-%\s*)/g
72
+ const newstr = texto?.replace(re, ' ')
73
+ return newstr
74
+ }
75
+
76
+ function captura (texto) {
77
+ const re = /(\s*%-\s*[a-zA-Z-0-9\s*]+\s*-%\s*)/g
78
+ const newstr = texto.match(re)
79
+ return newstr
80
+ }
81
+
82
+ function replaceTraducao (texto, textDeTraducao) {
83
+ const array = captura(texto)
84
+ if (array != null) {
85
+ array.forEach(element => {
86
+ element = element.replace('%-', '')
87
+ element = element.replace('-%', '')
88
+ const text = element.trim()
89
+ const re = /(\s*%-\s*[a-zA-Z-0-9\s*]+\s*-%\s*)/
90
+ textDeTraducao = textDeTraducao.replace(re, ' ' + text + ' ')
91
+ })
92
+ }
93
+ return textDeTraducao
94
+ }
95
+
96
+ export const MeIsTipoEntidade = function (entidade, permission) {
97
+ let result = false
98
+ // console.log(entidade.nome, permission)
99
+ if (entidade.nome === permission) {
100
+ result = true
101
+ }
102
+
103
+ return result
104
+ }
105
+
106
+ // Initialize the annoying-background directive.
107
+ export const IsTipoEntidade = {
108
+ bind (el, binding, _vnode) {
109
+ if (el) {
110
+ const ite = decrypt(localStorage.getItem(('tipo_entidade_nome')) + '')
111
+
112
+ if (!(binding.value === ite)) {
113
+ el.style.display = 'none'
114
+ }
115
+ }
116
+ }
117
+ }
118
+
119
+ export const isTipoEntidadeMe = function (x) {
120
+ const ite = decrypt(localStorage.getItem(('tipo_entidade_nome')) + '')
121
+ if (x === ite) { return true } else { return false }
122
+ }
123
+
124
+ export const urlBase = (url = '') => {
125
+ if (url === '') {
126
+ return process.env.API
127
+ }
128
+
129
+ if (url != null) {
130
+ if (url[0] === '/') {
131
+ return process.env.API + url
132
+ }
133
+ if (url[0] === 'h') {
134
+ return url
135
+ }
136
+ }
137
+ }
138
+
139
+ function base64url (source) {
140
+ const CryptoJS = require('crypto-js')
141
+ // Encode in classical base64
142
+ let encodedSource = CryptoJS.enc.Base64.stringify(source)
143
+
144
+ // Remove padding equal characters
145
+ encodedSource = encodedSource.replace(/=+$/, '')
146
+
147
+ // Replace characters according to base64url specifications
148
+ encodedSource = encodedSource.replace(/\+/g, '-')
149
+ encodedSource = encodedSource.replace(/\//g, '_')
150
+
151
+ return encodedSource
152
+ }
153
+
154
+ export const createToken = (data, secret = 'se') => {
155
+ // const base64url = require('base64url');
156
+ const CryptoJS = require('crypto-js')
157
+ const header = {
158
+ alg: 'HS256',
159
+ typ: 'JWT'
160
+ }
161
+
162
+ const stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header))
163
+ const encodedHeader = base64url(stringifiedHeader)
164
+
165
+ const stringifiedData = CryptoJS.enc.Utf8.parse(JSON.stringify(data))
166
+ const encodedData = base64url(stringifiedData)
167
+
168
+ const token = encodedHeader + '.' + encodedData
169
+
170
+ let signature = CryptoJS.HmacSHA256(token, secret)
171
+ signature = base64url(signature)
172
+
173
+ const signedToken = token + '.' + signature
174
+
175
+ return signedToken
176
+ }
177
+
178
+ export const setCookie = (cname, cvalue, exdays) => {
179
+ const d = new Date()
180
+ d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000))
181
+ const expires = 'expires=' + d.toUTCString()
182
+ document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/'
183
+ }
184
+
185
+ export const setStorage = (_type, _cname, _cvalue, _exdays) => {
186
+ if (_type === 'l') {
187
+ localStorage.setItem(_cname, _cvalue)
188
+ }
189
+
190
+ if (_type === 'c') {
191
+ setCookie(_cname, _cvalue, _exdays)
192
+ }
193
+ }
194
+
195
+ export const getCookie = (cname, _help = 0) => {
196
+ const name = cname + '='
197
+ const ca = document.cookie.split(';')
198
+ for (let i = 0; i < ca.length; i++) {
199
+ let c = ca[i]
200
+ while (c.charAt(0) === ' ') {
201
+ c = c.substring(1)
202
+ }
203
+ if (c.indexOf(name) === 0) {
204
+ return c.substring(name.length, c.length)
205
+ }
206
+ }
207
+ if (_help === 0) {
208
+ return ''
209
+ } else {
210
+ return null
211
+ }
212
+ }
213
+
214
+ export const getStorage = (_type, _cname, _help = 0) => {
215
+ let result = null
216
+ if (_type === 'l') {
217
+ result = localStorage.getItem(_cname)
218
+ }
219
+
220
+ if (_type === 'c') {
221
+ if (_help === 0) {
222
+ result = getCookie(_cname)
223
+ } else {
224
+ result = getCookie(_cname, _help)
225
+ }
226
+ }
227
+ return result
228
+ }
229
+
230
+ export const deleteStorage = (_type, _cname) => {
231
+ let result = null
232
+ if (_type === 'l') {
233
+ result = localStorage.removeItem(_cname)
234
+ }
235
+
236
+ if (_type === 'c') {
237
+ setCookie(_cname, null, 0)
238
+ }
239
+ return result
240
+ }
241
+
242
+
package/boot/config.js ADDED
@@ -0,0 +1,117 @@
1
+ import { getStorage, setStorage } from './storage'
2
+
3
+ import { url } from './api'
4
+
5
+ export const getHostname = (tipoEnt) => {
6
+ const domain = window.location.href.split('/')[2].split('.')[0]
7
+ if (domain.toLocaleLowerCase() !== tipoEnt.nome.toLowerCase()) {
8
+ return true
9
+ } else {
10
+ this.$store.commit('tipoEntidade/SET_TIPO_ENTIDADE', tipoEnt)
11
+ setStorage('c', 'tipoEntidade', JSON.stringify(tipoEnt))
12
+ location.reload()
13
+ return false
14
+ }
15
+ }
16
+
17
+ export const getTipoEntidades = async () => {
18
+ try {
19
+ const response = await fetch(url({ type: 'nu', url: 'tipoEntidades/', params: { } }), {
20
+ method: 'GET'
21
+ }).then(response => {
22
+ this.$store.commit('tipoEntidade/SET_TIPO_ENTIDADES', response?.data?.results)
23
+ response?.data?.results.forEach(tipoEntidade => {
24
+ getHostname(tipoEntidade)
25
+ })
26
+ })
27
+ return response
28
+ } catch (error) {
29
+ console.warn('conf.js => 29' + error.message)
30
+ }
31
+ }
32
+
33
+ export const getEntidade = async (id) => {
34
+ try {
35
+ const response = await fetch(url({ type: 'banu', url: 'entidades/' + id, params: { } }), {
36
+ method: 'GET'
37
+ }).then(response => {
38
+ this.$store.commit('entidade/SET_ENTIDADE', response?.data)
39
+ })
40
+ return response
41
+ } catch (error) {
42
+ console.warn('conf.js => 42' + error.message)
43
+ }
44
+ }
45
+
46
+ export const funcAppName = () => {
47
+ let name = ''
48
+ // console.log(getStorage('c', 'userEntidade'))
49
+ try {
50
+ if (getStorage('c', 'userEntidade', 2) === null) {
51
+ if (getStorage('c', 'tipoEntidade', 2) !== null) {
52
+ name = JSON.parse(getStorage('c', 'tipoEntidade', 2) + ' ')?.nome
53
+ }
54
+ }
55
+ } catch (error) {
56
+ console.warn('conf.js => 56' + error.message)
57
+ }
58
+ return name
59
+ }
60
+
61
+ export const funcAppLogo = () => {
62
+ let logo = ''
63
+ if (getStorage('c', 'userEntidade', 2) === null) {
64
+ // logo = process.env.API + JSON.parse(getStorage('c', 'tipoEntidade') + ' ')?.icon
65
+ if (getStorage('c', 'tipoEntidade', 2) !== null) {
66
+ logo = JSON.parse(getStorage('c', 'tipoEntidade', 2) + ' ')?.icon?.url
67
+ } else {
68
+ getTipoEntidades().then(res => {
69
+ try {
70
+ logo = res?.data?.tipoEntidade?.icon?.url
71
+ if (getStorage('l', 'rloadTipoEntidadeLogo') !== '1') {
72
+ setStorage('l', 'rloadTipoEntidadeLogo', 1)
73
+ window.location.reload()
74
+ }
75
+ } catch (error) {
76
+ console.warn('conf.js => 73' + error.message)
77
+ }
78
+ })
79
+ }
80
+ }
81
+ return logo
82
+ }
83
+
84
+ export const funcEntidadeName = () => {
85
+ let name = ''
86
+ if (getStorage('c', 'userEntidade', 2) !== null) {
87
+ name = JSON.parse(getStorage('c', 'userEntidade', 2) + ' ')?.nome
88
+ }
89
+ return name
90
+ }
91
+
92
+ export const funcEntidadeLogo = () => {
93
+ let logo = ''
94
+ if (getStorage('c', 'userEntidade', 2) !== null) {
95
+ logo = JSON.parse(getStorage('c', 'userEntidade', 2) + ' ')?.logo
96
+ } else {
97
+ getEntidade().then(res => {
98
+ try {
99
+ if (getStorage('l', 'rloadEntidadeLogo') !== '1') {
100
+ setStorage('l', 'rloadEntidadeLogo', 1)
101
+ window.location.reload()
102
+ }
103
+ } catch (error) {
104
+ console.warn('conf.js => 99' + error.message)
105
+ }
106
+ })
107
+ }
108
+
109
+ return logo
110
+ }
111
+
112
+ export const config = {
113
+ appName: funcAppName(),
114
+ appLogo: funcAppLogo(),
115
+ entidadeName: funcEntidadeName(),
116
+ entidadeLogo: funcEntidadeLogo()
117
+ }
package/boot/cripto.js ADDED
@@ -0,0 +1,35 @@
1
+
2
+ export const chavesenhacredencial = '@p0r@'
3
+
4
+ export const encrypt = (data, _secret = chavesenhacredencial) => {
5
+ const CryptoJS = require('crypto-js')
6
+
7
+ // Encrypt
8
+ const ciphertext = CryptoJS.AES.encrypt(data, chavesenhacredencial).toString()
9
+ return ciphertext
10
+ }
11
+
12
+ export const decrypt = (data, _secret = chavesenhacredencial) => {
13
+ const CryptoJS = require('crypto-js')
14
+ if (data != null && data !== 'null' && data !== '') {
15
+ const bytes = CryptoJS.AES.decrypt(data, chavesenhacredencial)
16
+ const originalText = bytes.toString(CryptoJS.enc.Utf8)
17
+ return originalText
18
+ }
19
+ return null
20
+ }
21
+ export const encryptKey = (data, _secret = chavesenhacredencial) => {
22
+ const CryptoJS = require('crypto-js')
23
+ const ciphertext = CryptoJS.AES.encrypt(data, chavesenhacredencial).toString()
24
+ return ciphertext
25
+ }
26
+
27
+ export const decryptKey = (data, _secret = chavesenhacredencial) => {
28
+ let retorno = null
29
+ Object.keys(localStorage).forEach(function (key) {
30
+ if (data === decrypt(key)) {
31
+ retorno = key
32
+ }
33
+ })
34
+ return retorno
35
+ }
package/boot/data.js ADDED
@@ -0,0 +1,28 @@
1
+ export const dateSplit = function (dataString = '') {
2
+ try {
3
+ dataString = dataString.replace('T', ' ')
4
+ } catch (error) {
5
+ }
6
+ let h = ''
7
+ let d = ''
8
+ const dataArray = dataString.split(' ')
9
+
10
+ function data (d) {
11
+ return d.split('-')[2] + '-' + d.split('-')[1] + '-' + d.split('-')[0]
12
+ }
13
+ function hora (h) {
14
+ return h.split(':')[0] + ':' + h.split(':')[1]
15
+ }
16
+ if (Array.isArray(dataArray) && dataArray.length > 1) {
17
+ d = data(dataArray[0])
18
+ h = hora(dataArray[1])
19
+ } else {
20
+ d = data(dataArray[0])
21
+ }
22
+
23
+ const l = (h !== '') ? (d + ' às ' + h) : d
24
+ if (l.includes('undefined')) {
25
+ return ''
26
+ }
27
+ return l
28
+ }
@@ -0,0 +1,74 @@
1
+
2
+ export const setCookie = (cname, cvalue, exdays) => {
3
+ const d = new Date()
4
+ d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000))
5
+ const expires = 'expires=' + d.toUTCString()
6
+ document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/'
7
+ }
8
+
9
+ export const setStorage = (_type, _cname, _cvalue, _exdays) => {
10
+ if (_type === 'l') {
11
+ localStorage.setItem(_cname, _cvalue)
12
+ }
13
+
14
+ if (_type === 'c') {
15
+ setCookie(_cname, _cvalue, _exdays)
16
+ }
17
+ }
18
+
19
+ export const getCookie = (cname, _help = 0) => {
20
+ const name = cname + '='
21
+ const ca = document.cookie.split(';')
22
+ for (let i = 0; i < ca.length; i++) {
23
+ let c = ca[i]
24
+ while (c.charAt(0) === ' ') {
25
+ c = c.substring(1)
26
+ }
27
+ if (c.indexOf(name) === 0) {
28
+ return c.substring(name.length, c.length)
29
+ }
30
+ }
31
+ if (_help === 0) {
32
+ return ''
33
+ } else {
34
+ return null
35
+ }
36
+ }
37
+
38
+ export const getStorage = (_type, _cname, _help = 0) => {
39
+ let result = null
40
+ if (_type === 'l') {
41
+ result = localStorage.getItem(_cname)
42
+ }
43
+
44
+ if (_type === 'c') {
45
+ if (_help === 0) {
46
+ result = getCookie(_cname)
47
+ } else {
48
+ result = getCookie(_cname, _help)
49
+ }
50
+ }
51
+ return result
52
+ }
53
+
54
+
55
+ export const deleteStorage = (_type, _cname) => {
56
+ let result = null
57
+ if (_type === 'l') {
58
+ result = localStorage.removeItem(_cname)
59
+ }
60
+
61
+ if (_type === 'c') {
62
+ setCookie(_cname, null, 0)
63
+ }
64
+ return result
65
+ }
66
+
67
+ export const localStorageSetItem = (key, value) => {
68
+ Object.keys(localStorage).forEach(function (keyLocal) {
69
+ if (key === decrypt(keyLocal)) {
70
+ localStorage.removeItem(keyLocal)
71
+ }
72
+ })
73
+ localStorage.setItem(encrypt(key), (value))
74
+ }
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <div class="q-pa-md q-gutter-sm">
3
+ <h2>Definicoes</h2>
4
+ </div>
5
+ </template>
6
+ <script >
7
+
8
+ import { defineComponent } from 'vue'
9
+ import { tdc } from '../boot/app'
10
+
11
+
12
+ export default defineComponent({
13
+ components: {
14
+
15
+ },
16
+ setup () {
17
+ },
18
+ data () {
19
+ return {
20
+ tdc: tdc,
21
+ }
22
+ },
23
+ methods: {
24
+
25
+ },
26
+ created () {
27
+ },
28
+ computed: {
29
+ },
30
+ mounted () {
31
+
32
+ }
33
+ })
34
+ </script>