@sowell/quasar-app-extension-auth 0.5.2 → 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.
package/.eslintrc.js CHANGED
@@ -6,7 +6,8 @@ module.exports = {
6
6
  },
7
7
  extends: [
8
8
  'eslint:recommended',
9
- 'plugin:vue/vue3-strongly-recommended',
9
+ 'plugin:@typescript-eslint/recommended',
10
+ 'plugin:vue/vue3-essential',
10
11
  'prettier'
11
12
  ],
12
13
  parserOptions: {
@@ -14,7 +15,7 @@ module.exports = {
14
15
  ecmaVersion: 2018,
15
16
  sourceType: 'module'
16
17
  },
17
- plugins: ['vue'],
18
+ plugins: ['vue', '@typescript-eslint'],
18
19
  rules: {
19
20
  'comma-dangle': ['error', 'only-multiline'],
20
21
  'space-before-function-paren': [
@@ -22,6 +23,9 @@ module.exports = {
22
23
  { anonymous: 'always', named: 'never', asyncArrow: 'always' }
23
24
  ],
24
25
  semi: 'off',
25
- 'no-unreachable': 'off'
26
+ quotes: ['error', 'double'],
27
+ 'no-unreachable': 'off',
28
+ 'array-bracket-spacing': ['error', 'never'],
29
+ 'func-call-spacing': ['error', 'never']
26
30
  }
27
31
  };
package/.prettierrc ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "singleQuote": false,
3
+ "semi": false,
4
+ "tabWidth": 2,
5
+ "trailingComma": "none",
6
+ "arrowParens": "always",
7
+ "bracketSameLine": true,
8
+ "bracketSpacing": true
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sowell/quasar-app-extension-auth",
3
- "version": "0.5.2",
3
+ "version": "1.0.1",
4
4
  "description": "A Quasar app extension to manage Authentication",
5
5
  "main": "src/index.js",
6
6
  "repository": "https://github.com/sowell-ai/quasar.extension.auth",
@@ -22,17 +22,16 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@quasar/cli": "^2.2.3",
25
- "@quasar/quasar-app-extension-testing-e2e-cypress": "^3.1.0",
26
25
  "@types/node": "^16.9.1",
27
26
  "@types/validator": "^13.6.3",
28
- "cypress-cucumber-preprocessor": "^4.3.0",
27
+ "@typescript-eslint/eslint-plugin": "^5.10.0",
28
+ "@typescript-eslint/parser": "^5.10.0",
29
29
  "eslint": "^7.14.0",
30
30
  "eslint-config-prettier": "^8.1.0",
31
31
  "eslint-plugin-cypress": "^2.11.1",
32
32
  "eslint-plugin-vue": "^7.0.0",
33
33
  "jwt-decode": "^3.1.2",
34
- "quasar": "^2.6.2",
35
- "vue": "3.4.21",
34
+ "quasar": "^2.8.4",
36
35
  "typescript": "^4.4.2"
37
36
  },
38
37
  "directories": {
@@ -40,7 +39,7 @@
40
39
  },
41
40
  "dependencies": {
42
41
  "@capacitor/core": "^4.6.2",
43
- "@quasar/extras": "^1.13.4",
42
+ "@quasar/extras": "^1.15.2",
44
43
  "axios": "^0.21.1",
45
44
  "buffer": "^6.0.3",
46
45
  "pinia": "^2.0.12",
@@ -82,51 +82,53 @@ import { useI18n } from "vue-i18n";
82
82
  export default defineComponent({
83
83
  props: {
84
84
  emailResetPassword: {
85
- type: String,
85
+ type: String
86
86
  },
87
87
  sendEmailSuccess: {
88
- type: Boolean,
88
+ type: Boolean
89
89
  },
90
90
  loading: {
91
- type: Boolean,
91
+ type: Boolean
92
92
  },
93
93
  passwordUpdated: {
94
- type: Boolean,
95
- },
94
+ type: Boolean
95
+ }
96
96
  },
97
- emit: ["retypeEmail", "goToLoginPage"],
97
+ emit: ["retypeEmail", "goToLoginPage", "close"],
98
98
  setup(props: any, { emit }: any) {
99
- const { t } = useI18n();
99
+ const { t } = useI18n()
100
100
 
101
101
  const messageSubtitle = computed(() =>
102
102
  props.sendEmailSuccess
103
103
  ? t("auth.emailSent")
104
104
  : !props.passwordUpdated
105
105
  ? t("auth.emailNotRecognize")
106
- : t("auth.passwordUpdated"),
107
- );
106
+ : t("auth.passwordUpdated")
107
+ )
108
108
  const messageTitle = computed(() =>
109
109
  props.sendEmailSuccess
110
110
  ? t("auth.emailVerification")
111
111
  : !props.passwordUpdated
112
112
  ? t("auth.loginFailed")
113
- : t("auth.passwordChanged"),
114
- );
113
+ : t("auth.passwordChanged")
114
+ )
115
115
 
116
116
  const emailNotSend = computed(
117
117
  () => !props.sendEmailSuccess && !props.passwordUpdated
118
- );
118
+ )
119
119
  const emailSended = computed(
120
120
  () => props.sendEmailSuccess && !props.passwordUpdated
121
- );
121
+ )
122
122
 
123
123
  const retypeEmail = () => {
124
- emit("retypeEmail");
125
- };
124
+ emit("retypeEmail")
125
+ }
126
126
 
127
127
  const handlePasswordUpdate = () =>{
128
128
  if(props.passwordUpdated){
129
129
  emit("goToLoginPage")
130
+ } else {
131
+ emit("close")
130
132
  }
131
133
  }
132
134
 
@@ -136,8 +138,8 @@ export default defineComponent({
136
138
  emailNotSend,
137
139
  emailSended,
138
140
  handlePasswordUpdate,
139
- retypeEmail,
140
- };
141
- },
142
- });
141
+ retypeEmail
142
+ }
143
+ }
144
+ })
143
145
  </script>
@@ -1,19 +1,21 @@
1
1
  <template>
2
- <q-card
2
+ <div
3
3
  class="row justify-center full-height q-pl-sm q-pr-sm"
4
4
  style="background: #f4f5f6"
5
5
  data-testid="ask-password-change-form"
6
6
  >
7
- <q-page class="column" style="max-width: 447px">
7
+ <div class="column" style="max-width: 447px">
8
8
  <q-card-section>
9
- <q-btn
10
- class="q-pt-md"
11
- flat
12
- dense
13
- size="10px"
14
- icon="arrow_back_ios_new"
15
- v-close-popup
16
- />
9
+ <div>
10
+ <q-btn
11
+ class="q-py-md"
12
+ flat
13
+ dense
14
+ size="10px"
15
+ icon="arrow_back_ios_new"
16
+ @click="emit('close')"
17
+ />
18
+ </div>
17
19
  </q-card-section>
18
20
  <q-card-section class="">
19
21
  <div
@@ -71,36 +73,38 @@
71
73
  v-close-popup
72
74
  />
73
75
  </q-card-actions>
74
- </q-page>
75
- </q-card>
76
+ </div>
77
+ </div>
76
78
  </template>
77
79
 
78
80
  <script lang="ts">
81
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
79
82
  // @ts-ignore
80
- import { defineComponent, ref } from "vue";
83
+ import { defineComponent, ref } from "vue"
81
84
  import {
82
85
  ionMailOutline,
83
86
  ionPaperPlaneOutline,
84
- } from "@quasar/extras/ionicons-v5";
87
+ } from "@quasar/extras/ionicons-v5"
85
88
 
86
89
  export default defineComponent({
87
- emit: ["resetPassword"],
90
+ emit: ["resetPassword", "close"],
88
91
  setup(props: any, { emit }: any) {
89
- const email = ref("");
92
+ const email = ref("")
90
93
  const sendEmail = () => {
91
- emit("resetPassword", email.value);
92
- };
94
+ emit("resetPassword", email.value)
95
+ }
93
96
 
94
97
  return {
95
98
  email,
96
99
  sendEmail,
100
+ emit,
97
101
  icons: {
98
102
  ionMailOutline,
99
103
  ionPaperPlaneOutline,
100
- },
101
- };
102
- },
103
- });
104
+ }
105
+ }
106
+ }
107
+ })
104
108
  </script>
105
109
  <style scoped>
106
110
  @media screen and (min-width: 450px) {
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <q-card data-testid="ask-password-change-form">
3
- <q-page class="row bg-white">
3
+ <div class="row bg-white">
4
4
  <div class="col-6 q-pa-xl row justify-center center">
5
5
  <div class="left-side full-width full-height">
6
6
  <img
@@ -58,6 +58,7 @@
58
58
  :label="$t('auth.login')"
59
59
  class="btn-min"
60
60
  v-close-popup
61
+ @click="emit('close')"
61
62
  />
62
63
  </div>
63
64
  </div>
@@ -70,38 +71,40 @@
70
71
  alt=""
71
72
  />
72
73
  </div>
73
- </q-page>
74
+ </div>
74
75
  </q-card>
75
76
  </template>
76
77
 
77
78
  <script lang="ts">
79
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
78
80
  // @ts-ignore
79
- import { defineComponent, ref } from "vue";
80
- import prompts from "app/quasar.extensions.json";
81
- import { ionPaperPlaneOutline } from "@quasar/extras/ionicons-v5";
81
+ import { defineComponent, ref } from "vue"
82
+ import prompts from "app/quasar.extensions.json"
83
+ import { ionPaperPlaneOutline } from "@quasar/extras/ionicons-v5"
82
84
 
83
85
  export default defineComponent({
84
86
  name: "WebSendMail",
85
- emit: ["resetPassword"],
87
+ emit: ["resetPassword", "close"],
86
88
  setup(props: any, { emit }: any) {
87
89
  const {
88
90
  "@sowell/auth": { FORGOTTEN_PASSWORD_TITLE, FORGOTTEN_PASSWORD_SUBTITLE },
89
- } = prompts;
90
- const email = ref("");
91
+ } = prompts
92
+ const email = ref("")
91
93
  const sendEmail = () => {
92
- emit("resetPassword", email.value);
93
- };
94
+ emit("resetPassword", email.value)
95
+ }
94
96
  return {
95
97
  email,
96
98
  FORGOTTEN_PASSWORD_TITLE,
97
99
  FORGOTTEN_PASSWORD_SUBTITLE,
98
100
  sendEmail,
101
+ emit,
99
102
  icons: {
100
- ionPaperPlaneOutline,
101
- },
102
- };
103
- },
104
- });
103
+ ionPaperPlaneOutline
104
+ }
105
+ }
106
+ }
107
+ })
105
108
  </script>
106
109
 
107
110
  <style scoped>
@@ -14,7 +14,7 @@
14
14
  />
15
15
  </div>
16
16
  <div class="row justify-center">
17
- <img :src="image" />
17
+ <img :src="imageValue" />
18
18
  </div>
19
19
  </q-card-section>
20
20
 
@@ -42,7 +42,7 @@
42
42
  outline
43
43
  no-caps
44
44
  :label="$t('auth.close')"
45
- @click="passwordUpdated ? $emit('goToLoginPage') : ''"
45
+ @click="passwordUpdated ? $emit('goToLoginPage') : $emit('close')"
46
46
  color="primary"
47
47
  v-close-popup
48
48
  />
@@ -67,9 +67,9 @@ export default defineComponent({
67
67
  passwordUpdated: { type: Boolean },
68
68
  isOtp: { type: Boolean, default: false, required: false },
69
69
  },
70
- emit: ["goToLoginPage"],
70
+ emit: ["goToLoginPage", "close"],
71
71
  setup(props: any) {
72
- const image = computed(() => {
72
+ const imageValue = computed(() => {
73
73
  switch (props.image) {
74
74
  case "userNotFound":
75
75
  return userNotFound;
@@ -79,9 +79,12 @@ export default defineComponent({
79
79
 
80
80
  case "emailVerification":
81
81
  return emailVerification;
82
+ default:
83
+ return null
82
84
  }
83
- });
84
- return { image, icons: { ionCloseOutline } };
85
+ })
86
+
87
+ return { imageValue, icons: { ionCloseOutline } };
85
88
  },
86
89
  });
87
90
  </script>
@@ -92,7 +92,7 @@
92
92
  transition-hide="fade"
93
93
  persistent
94
94
  >
95
- <web-send-email @resetPassword="resetPassword" />
95
+ <web-send-email @resetPassword="resetPassword" @close="() => forgottenPassword = false" />
96
96
  </q-dialog>
97
97
  <q-dialog v-model="isNotification" persistent>
98
98
  <sw-info-dialog
@@ -119,26 +119,22 @@
119
119
  </template>
120
120
 
121
121
  <script lang="ts">
122
- import isEmail from "validator/es/lib/isEmail";
123
- import { defineComponent, ref, computed } from "vue";
124
- import { useAuthState } from "../../injects";
125
- import { useI18n } from "vue-i18n";
126
- import SwInfoDialog from "../dialogs/sw-info-dialog.vue";
127
- import WebSendEmail from "../dialogs/WebSendEmail.vue";
122
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
123
+ //@ts-ignore
124
+ import { defineComponent, ref, computed } from "vue"
125
+ import { useI18n } from "vue-i18n"
126
+ import isEmail from "validator/es/lib/isEmail"
127
+ import { useAuthState } from "../../injects"
128
+ import SwInfoDialog from "../dialogs/sw-info-dialog.vue"
129
+ import WebSendEmail from "../dialogs/WebSendEmail.vue"
128
130
 
129
- import { useAuth } from "composables/auth";
130
-
131
- interface HeadersInterface {
132
- headers: {
133
- "x-requested-roles"?: string;
134
- };
135
- }
131
+ import { useAuth } from "composables/auth"
136
132
  export default defineComponent({
137
133
  name: "Auth",
138
134
  components: { WebSendEmail, SwInfoDialog },
139
135
  setup() {
140
- const { t } = useI18n();
141
- const authState = useAuthState();
136
+ const { t } = useI18n()
137
+ const authState = useAuthState()
142
138
 
143
139
  const {
144
140
  email,
@@ -153,25 +149,25 @@ export default defineComponent({
153
149
  X_REQUESTED_ROLES,
154
150
  IS_OTP,
155
151
  APP_SERVER_BASE_URL,
152
+ icons,
156
153
  goToOtpValidation,
157
154
  onSubmit,
158
155
  retypeEmail,
159
- isSubmitBtnDisabled,
160
- icons,
161
- } = useAuth();
156
+ isSubmitBtnDisabled
157
+ } = useAuth()
162
158
 
163
159
  const handleSubmit = () => {
164
160
  onSubmit()
165
161
  }
166
162
 
167
- const IS_ADMIN = ["admin"].includes(X_REQUESTED_ROLES);
168
- const isNotification = ref(false);
169
- const requestedOtp = ref(false);
163
+ const IS_ADMIN = ["admin"].includes(X_REQUESTED_ROLES)
164
+ const isNotification = ref(false)
165
+ const requestedOtp = ref(false)
170
166
  const infoDialog = ref({
171
167
  title: "",
172
168
  content: "",
173
- image: "",
174
- });
169
+ image: ""
170
+ })
175
171
 
176
172
  const submitBtnDisabled = computed(
177
173
  () =>
@@ -181,41 +177,41 @@ export default defineComponent({
181
177
  password.value &&
182
178
  password.value.length > 5
183
179
  )
184
- );
180
+ )
185
181
  const resetPassword = async (email: string) => {
186
182
  if (email) {
187
183
  const data = {
188
184
  auth: {
189
185
  email,
190
186
  base: APP_SERVER_BASE_URL,
191
- },
192
- };
187
+ }
188
+ }
193
189
  try {
194
190
  await authState.resetPassword(data).then(() => {
195
- localStorage.setItem("emailResetPassword", email);
191
+ localStorage.setItem("emailResetPassword", email)
196
192
  infoDialog.value = {
197
193
  title: t("auth.mailVerificationTitle"),
198
194
  content:
199
195
  IS_OTP.toLowerCase() === "y"
200
196
  ? t("auth.otpValidationCode")
201
197
  : t("auth.mailVerificationSubtitle"),
202
- image: "emailVerification",
203
- };
204
- forgottenPassword.value = false;
205
- isNotification.value = true;
206
- requestedOtp.value = true;
207
- });
198
+ image: "emailVerification"
199
+ }
200
+ forgottenPassword.value = false
201
+ isNotification.value = true
202
+ requestedOtp.value = true
203
+ })
208
204
  } catch {
209
- requestedOtp.value = false;
205
+ requestedOtp.value = false
210
206
  infoDialog.value = {
211
207
  title: t("auth.userNotFoundTitle"),
212
208
  content: t("auth.userNotFoundSubtitle"),
213
- image: "userNotFound",
214
- };
215
- isNotification.value = true;
209
+ image: "userNotFound"
210
+ }
211
+ isNotification.value = true
216
212
  }
217
213
  }
218
- };
214
+ }
219
215
 
220
216
  return {
221
217
  email,
@@ -231,16 +227,16 @@ export default defineComponent({
231
227
  IS_ADMIN,
232
228
  WELCOME_SUBTITLE,
233
229
  WELCOME_TITLE,
234
- isSubmitBtnDisabled,
235
230
  requestedOtp,
231
+ icons,
232
+ isSubmitBtnDisabled,
236
233
  goToOtpValidation,
237
234
  resetPassword,
238
235
  retypeEmail,
239
- handleSubmit,
240
- icons,
241
- };
242
- },
243
- });
236
+ handleSubmit
237
+ }
238
+ }
239
+ })
244
240
  </script>
245
241
 
246
242
  <style scoped>