@hostlink/nuxt-light 0.0.74 → 0.0.75

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/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.74"
4
+ "version": "0.0.75"
5
5
  }
@@ -10,7 +10,7 @@ setApiUrl(config?.public?.apiBase ?? '/api/');
10
10
  let app = null
11
11
 
12
12
  try {
13
- app = (await q({ app: ['company', 'companyLogo', 'logged', 'twoFactorAuthentication'] })).app;
13
+ app = (await q({ app: ['company', 'companyLogo', 'logged', 'twoFactorAuthentication', 'googleClientId'] })).app;
14
14
  } catch (e) {
15
15
  Dialog.create({
16
16
  title: 'Error',
@@ -28,7 +28,7 @@ try {
28
28
  <q-page-container class="bg-grey-2" style="color:#1f1f1f">
29
29
  <q-page padding>
30
30
  <l-login :company="app.company" :company-logo="app.companyLogo"
31
- :twoFactorAuthentication="app.twoFactorAuthentication"></l-login>
31
+ :twoFactorAuthentication="app.twoFactorAuthentication" :google-client-id="app.googleClientId"></l-login>
32
32
  </q-page>
33
33
  </q-page-container>
34
34
  </q-layout>
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { ref, reactive, onMounted } from 'vue'
3
- import { useQuasar } from 'quasar';
3
+ import { useQuasar, Notify } from 'quasar';
4
4
  import { useI18n } from 'vue-i18n';
5
5
  import { m, notify } from '../';
6
6
 
@@ -11,10 +11,11 @@ import { login, webauthnLogin } from '@hostlink/light';
11
11
  const config = useRuntimeConfig();
12
12
 
13
13
 
14
- defineProps({
14
+ const props = defineProps({
15
15
  company: String,
16
16
  companyLogo: String,
17
- twoFactorAuthentication: Boolean
17
+ twoFactorAuthentication: Boolean,
18
+ googleClientId: String
18
19
  })
19
20
 
20
21
  const i18n = useI18n();
@@ -123,16 +124,35 @@ const bioLogin = async () => {
123
124
  }
124
125
 
125
126
  }
126
- const googleResponse = () => {
127
-
127
+ const handleGoogleCredentialResponse = async (response) => {
128
+ try {
129
+ await m("googleLogin", { credential: response.credential });
130
+ window.self.location.reload();
131
+ } catch (e) {
132
+ notify(e.message, "negative");
133
+ }
128
134
  }
129
135
 
130
136
  onMounted(() => {
131
- if (config.public.GOOGLE_CLIENT_ID) {
137
+ if (props.googleClientId) {
138
+
139
+
140
+ if (!window.google) {
141
+ Notify.create({
142
+ message: "Google login is not available", //set script https://accounts.google.com/gsi/client in nuuxt.config.js
143
+ color: "negative",
144
+ icon: "sym_o_error",
145
+ position: "top",
146
+ timeout: 2000
147
+ });
148
+ return;
149
+
150
+ }
151
+
132
152
  //google
133
153
  google.accounts.id.initialize({
134
- client_id: "829616239009-23sf7s3blsnab9a288sb4j15orqqamlp.apps.googleusercontent.com",
135
- callback: googleResponse,
154
+ client_id: props.googleClientId,
155
+ callback: handleGoogleCredentialResponse,
136
156
  });
137
157
 
138
158
  google.accounts.id.renderButton(
@@ -144,7 +164,6 @@ onMounted(() => {
144
164
  text: 'signin_with',
145
165
  size: 'large',
146
166
  logo_alignment: 'left'
147
-
148
167
  }
149
168
  );
150
169
 
@@ -179,13 +198,10 @@ onMounted(() => {
179
198
  <l-btn v-if="hasBioLogin" outline rounded color="primary" icon="sym_o_fingerprint" @click="bioLogin" />
180
199
  <l-btn label="Forget password" outline rounded color="primary" icon="sym_o_lock_reset" @click="forgetPassword" />
181
200
  </q-card-actions>
182
- <q-card-actions v-if="config.public.GOOGLE_CLIENT_ID">
183
-
201
+ <q-card-actions v-if="props.googleClientId">
184
202
  <div>
185
-
186
203
  <div id="g_id_signin"></div>
187
204
  </div>
188
-
189
205
  </q-card-actions>
190
206
  </q-card>
191
207
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.74",
3
+ "version": "0.0.75",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",