@thzero/library_client_firebase 0.16.7 → 0.16.9
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.
- package/boot/starter.js +2 -111
- package/package.json +2 -2
package/boot/starter.js
CHANGED
|
@@ -9,16 +9,14 @@ import GlobalUtility from '@thzero/library_client/utility/global';
|
|
|
9
9
|
import config from 'local-config';
|
|
10
10
|
|
|
11
11
|
// export default async ({
|
|
12
|
-
export default ({
|
|
13
|
-
setup
|
|
14
|
-
}) => {
|
|
12
|
+
export default (setup) => {
|
|
15
13
|
const configExternal = config.external;
|
|
16
14
|
if (!configExternal)
|
|
17
15
|
throw Error('Invalid external config.');
|
|
18
16
|
const configFirebase = configExternal.firebase;
|
|
19
17
|
if (!configFirebase)
|
|
20
18
|
throw Error('Invalid firebase config.');
|
|
21
|
-
|
|
19
|
+
initializeApp(configFirebase);
|
|
22
20
|
if (configFirebase.measurementId)
|
|
23
21
|
getAnalytics();
|
|
24
22
|
|
|
@@ -30,29 +28,11 @@ export default ({
|
|
|
30
28
|
});
|
|
31
29
|
|
|
32
30
|
const firebaseAuth = getAuth();
|
|
33
|
-
// if (firebaseAuth.currentUser) {
|
|
34
|
-
// const timer = setInterval(async () => {
|
|
35
|
-
// clearInterval(timer)
|
|
36
|
-
// const auth = GlobalUtility.$injector.getService(LibraryConstants.InjectorKeys.SERVICE_AUTH)
|
|
37
|
-
// await auth.onAuthStateChanged(null)
|
|
38
|
-
// }, 50)
|
|
39
|
-
// }
|
|
40
31
|
// eslint-disable-next-line
|
|
41
32
|
let init = false;
|
|
42
33
|
firebaseAuth.onAuthStateChanged(async function(user) {
|
|
43
|
-
// if (user == null) {
|
|
44
|
-
// // GlobalUtility.$navRouter.push('/auth')
|
|
45
|
-
// return
|
|
46
|
-
// }
|
|
47
|
-
|
|
48
34
|
const auth = GlobalUtility.$injector.getService(LibraryConstants.InjectorKeys.SERVICE_AUTH);
|
|
49
|
-
// await auth.onAuthStateChanged(user)
|
|
50
|
-
// const timer = setInterval(async () => {
|
|
51
|
-
// clearInterval(timer)
|
|
52
|
-
// await auth.onAuthStateChanged(user)
|
|
53
|
-
// }, 50)
|
|
54
35
|
await auth.onAuthStateChanged(user);
|
|
55
|
-
// if (test)
|
|
56
36
|
if (!init) {
|
|
57
37
|
init = true;
|
|
58
38
|
outsideResolve(true);
|
|
@@ -62,96 +42,7 @@ export default ({
|
|
|
62
42
|
outsideReject();
|
|
63
43
|
});
|
|
64
44
|
|
|
65
|
-
// setInterval(async () => {
|
|
66
|
-
// const logger = GlobalUtility.$injector.getService(LibraryConstants.InjectorKeys.SERVICE_LOGGER)
|
|
67
|
-
// const auth = GlobalUtility.$injector.getService(LibraryConstants.InjectorKeys.SERVICE_AUTH)
|
|
68
|
-
// try {
|
|
69
|
-
// await auth.refreshToken(correlationId, auth.externalUser, true).then()
|
|
70
|
-
// }
|
|
71
|
-
// catch (err) {
|
|
72
|
-
// logger.error(err)
|
|
73
|
-
// }
|
|
74
|
-
// }, 60 * 1000)
|
|
75
|
-
|
|
76
|
-
// firebase.auth().onIdTokenChanged(async function(user) {
|
|
77
|
-
// const logger = GlobalUtility.$injector.getService(LibraryConstants.InjectorKeys.SERVICE_LOGGER)
|
|
78
|
-
// try {
|
|
79
|
-
// const auth = GlobalUtility.$injector.getService(LibraryConstants.InjectorKeys.SERVICE_AUTH)
|
|
80
|
-
|
|
81
|
-
// // const interval = 500 // 10 * 1000
|
|
82
|
-
// // const timer = setInterval(async () => {
|
|
83
|
-
// // await auth.onRefresh(user)
|
|
84
|
-
// // clearInterval(timer)
|
|
85
|
-
// // }, interval)
|
|
86
|
-
// await auth.onRefresh(user)
|
|
87
|
-
// }
|
|
88
|
-
// catch (err) {
|
|
89
|
-
// logger.error(err)
|
|
90
|
-
// }
|
|
91
|
-
// })
|
|
92
|
-
|
|
93
45
|
setup();
|
|
94
|
-
// router.beforeResolve((to, from, next) => {
|
|
95
|
-
// const auth = GlobalUtility.$injector.getService(LibraryConstants.InjectorKeys.SERVICE_AUTH);
|
|
96
|
-
// const logger = GlobalUtility.$injector.getService(LibraryConstants.InjectorKeys.SERVICE_LOGGER);
|
|
97
|
-
// logger.debug('router.beforeResolve', to);
|
|
98
|
-
// if (to.matched.some(record => record.meta.requiresAuth)) {
|
|
99
|
-
// const isLoggedIn = auth.isAuthenticated;
|
|
100
|
-
// if (!isLoggedIn) {
|
|
101
|
-
// // GlobalUtility.$EventBus.on('auth-refresh', (user) => {
|
|
102
|
-
// // logger.debug('auth-refresh', user)
|
|
103
|
-
// // next()
|
|
104
|
-
// // })
|
|
105
|
-
// // return
|
|
106
|
-
// GlobalUtility.$navRouter.push('/', null, () => {
|
|
107
|
-
// // GlobalUtility.$navRouter.push('/')
|
|
108
|
-
// // window.location.href = '/'
|
|
109
|
-
// });
|
|
110
|
-
// return;
|
|
111
|
-
// }
|
|
112
|
-
|
|
113
|
-
// next();
|
|
114
|
-
|
|
115
|
-
// // eslint-disable-next-line no-unused-vars
|
|
116
|
-
// // auth.isAuthenticated().then(async (data) => {
|
|
117
|
-
// // logger.debug('router.beforeResolve.matched')
|
|
118
|
-
|
|
119
|
-
// // //const isLoggedIn = GlobalUtility.$store.state.user.isLoggedIn
|
|
120
|
-
// // const isLoggedIn = await auth.isAuthenticated()
|
|
121
|
-
// // if (!isLoggedIn) {
|
|
122
|
-
// // GlobalUtility.$EventBus.on('auth-refresh', (user) => {
|
|
123
|
-
// // logger.debug('auth-refresh', user)
|
|
124
|
-
// // next()
|
|
125
|
-
// // })
|
|
126
|
-
// // return
|
|
127
|
-
// // }
|
|
128
|
-
|
|
129
|
-
// // // if (GlobalUtility.$store.state.user.token) {
|
|
130
|
-
// // // next()
|
|
131
|
-
// // // return
|
|
132
|
-
// // // }
|
|
133
|
-
|
|
134
|
-
// // // GlobalUtility.$EventBus.on('auth-refresh', (user) => {
|
|
135
|
-
// // // logger.debug('auth-refresh', user)
|
|
136
|
-
// // // next()
|
|
137
|
-
// // // })
|
|
138
|
-
|
|
139
|
-
// // next()
|
|
140
|
-
// // }).catch((e) => {
|
|
141
|
-
// // logger.error('router.beforeResolve.error', e)
|
|
142
|
-
// // logger.error('to', to)
|
|
143
|
-
// // logger.error('from', from)
|
|
144
|
-
// // if (to.name == 'auth') {
|
|
145
|
-
// // next()
|
|
146
|
-
// // return
|
|
147
|
-
// // }
|
|
148
|
-
// // next({ path: '/auth' })
|
|
149
|
-
// // })
|
|
150
|
-
|
|
151
|
-
// return;
|
|
152
|
-
// }
|
|
153
|
-
// next();
|
|
154
|
-
// });
|
|
155
46
|
|
|
156
47
|
return promiseAuth;
|
|
157
48
|
};
|
package/package.json
CHANGED