@sowell/quasar-app-extension-auth 0.2.2 → 0.2.3
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/package.json +1 -1
- package/src/assets/Logo.svg +6 -0
- package/src/components/pages/Auth.vue +139 -101
- package/src/i18n/en-US/index.ts +1 -0
- package/src/i18n/fr-FR/index.ts +1 -0
- package/src/prompts.js +9 -3
package/package.json
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="39.779" height="70.275" viewBox="0 0 39.779 70.275">
|
|
2
|
+
<g id="Logo_Sowell_bleu" data-name="Logo Sowell bleu" transform="translate(-403.55 -422.444)">
|
|
3
|
+
<path id="Tracé_455" data-name="Tracé 455" d="M440.01,457.9l-9.08-19.791a4,4,0,0,0-5.243-2.083h0a4,4,0,0,0-2.083,5.243l4.939,11.466a19.894,19.894,0,0,0-20.414,6.519,4.349,4.349,0,0,0-.21,1.945c0,2.45,2.091,4.11,4.578,4.11a4.524,4.524,0,0,0,3.021-1.149c1.98-1.693,5.1-3.689,7.905-3.689a11.327,11.327,0,1,1-11.3,12.2c.065-1.637.144-2.7.144-2.7a4.326,4.326,0,0,0-8.417-1.406l-.018-.009c-.006.039-.012.078-.019.118a4.317,4.317,0,0,0-.2,1.3c0,.072,0,.149.006.223q-.072.862-.076,1.74a19.814,19.814,0,0,0,5.441,13.66l14.429,19.43,15.461-20.608h0a21.785,21.785,0,0,0,4.413-12.484C443.729,465.218,440.01,457.9,440.01,457.9Z" transform="translate(0 -12.306)" fill="#40c4ff"/>
|
|
4
|
+
<path id="Tracé_456" data-name="Tracé 456" d="M802.618,443.124l-.884-17.044a4,4,0,0,0-4.326-3.622h0a3.985,3.985,0,0,0-2.968,1.771Z" transform="translate(-362.817 0)" fill="#40c4ff"/>
|
|
5
|
+
</g>
|
|
6
|
+
</svg>
|
|
@@ -1,113 +1,106 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<q-layout>
|
|
3
|
-
<q-page-
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
<q-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
<q-page class="column justify-center items-center">
|
|
4
|
+
<div class="q-pa-xl">
|
|
5
|
+
<div class="column justify-ceter">
|
|
6
|
+
<img src="../../assets/Logo.svg" class="q-mb-sm" />
|
|
7
|
+
<div class="text-subtitle1 text-center head" style="font-weight: 600">
|
|
8
|
+
{{ $t("auth.title") }}
|
|
9
|
+
</div>
|
|
10
|
+
<div class="q-mt-xl q-mb-lg text-subtitle1" style="font-size: 14px">
|
|
11
|
+
{{ $t("auth.loginHelp") }}
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
<q-form @submit="onSubmit">
|
|
15
|
+
<q-input
|
|
16
|
+
data-cy="email"
|
|
17
|
+
v-model.trim="email"
|
|
18
|
+
type="email"
|
|
19
|
+
:label="$t('auth.email')"
|
|
20
|
+
:rules="validations['email']"
|
|
21
|
+
lazy-rules
|
|
22
|
+
dense
|
|
23
|
+
:input-style="{ fontSize: '14px', fontWeight: '500' }"
|
|
24
|
+
/>
|
|
25
|
+
<q-input
|
|
26
|
+
data-cy="password"
|
|
27
|
+
v-model="password"
|
|
28
|
+
:type="showPassword ? 'text' : 'password'"
|
|
29
|
+
:label="$t('auth.password')"
|
|
30
|
+
:rules="validations['password']"
|
|
31
|
+
lazy-rules
|
|
32
|
+
dense
|
|
33
|
+
:input-style="{ fontSize: '14px', fontWeight: '600' }"
|
|
34
|
+
>
|
|
35
|
+
<template #append>
|
|
36
|
+
<q-icon
|
|
37
|
+
:name="showPassword ? 'visibility' : 'visibility_off'"
|
|
38
|
+
class="cursor-pointer"
|
|
39
|
+
@click="showPassword = !showPassword"
|
|
40
|
+
/>
|
|
41
|
+
</template>
|
|
42
|
+
</q-input>
|
|
43
|
+
<div
|
|
44
|
+
class="q-mb-xl"
|
|
45
|
+
@click="forgottenPassword = true"
|
|
46
|
+
style="color: #40c4ff; font-weight: 500; cursor: pointer"
|
|
47
|
+
>
|
|
48
|
+
{{ $t("auth.forgottenPassword") }}
|
|
49
|
+
</div>
|
|
50
|
+
<q-btn
|
|
51
|
+
data-cy="submit-login"
|
|
52
|
+
rounded
|
|
53
|
+
:label="$t('auth.login')"
|
|
54
|
+
style="background: #40c4ff"
|
|
55
|
+
no-caps
|
|
56
|
+
text-color="white"
|
|
57
|
+
:loading="loading"
|
|
58
|
+
type="submit"
|
|
59
|
+
class="full-width q-mt-lg"
|
|
60
|
+
:disable="isSubmitBtnDisabled()"
|
|
61
|
+
/>
|
|
62
|
+
</q-form>
|
|
63
|
+
</div>
|
|
64
|
+
<div>
|
|
65
|
+
<q-dialog v-model="forgottenPassword" persistent>
|
|
66
|
+
<q-card style="min-width: 350px">
|
|
13
67
|
<q-card-section>
|
|
68
|
+
<p class="resetPasswordTitle">
|
|
69
|
+
{{ $t("auth.tapEmail") }}
|
|
70
|
+
</p>
|
|
71
|
+
</q-card-section>
|
|
72
|
+
|
|
73
|
+
<q-card-section class="q-pt-none">
|
|
14
74
|
<q-input
|
|
15
|
-
|
|
16
|
-
v-model.trim="email"
|
|
17
|
-
type="email"
|
|
18
|
-
:label="$t('auth.email')"
|
|
19
|
-
:rules="validations['email']"
|
|
20
|
-
lazy-rules
|
|
21
|
-
autofocus
|
|
22
|
-
rounded
|
|
23
|
-
outlined
|
|
75
|
+
v-model="emailResetPassword"
|
|
24
76
|
dense
|
|
25
|
-
class="full-width q-mb-md"
|
|
26
|
-
/>
|
|
27
|
-
<q-input
|
|
28
|
-
data-cy="password"
|
|
29
|
-
v-model="password"
|
|
30
|
-
:type="showPassword ? 'text' : 'password'"
|
|
31
|
-
:label="$t('auth.password')"
|
|
32
|
-
:rules="validations['password']"
|
|
33
|
-
lazy-rules
|
|
34
77
|
rounded
|
|
35
78
|
outlined
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<template #append>
|
|
40
|
-
<q-icon
|
|
41
|
-
:name="showPassword ? 'visibility' : 'visibility_off'"
|
|
42
|
-
class="cursor-pointer"
|
|
43
|
-
@click="showPassword = !showPassword"
|
|
44
|
-
/>
|
|
45
|
-
</template>
|
|
46
|
-
</q-input>
|
|
79
|
+
:placeholder="$t('auth.email')"
|
|
80
|
+
autofocus
|
|
81
|
+
/>
|
|
47
82
|
</q-card-section>
|
|
48
|
-
|
|
83
|
+
|
|
84
|
+
<q-card-actions align="right">
|
|
49
85
|
<q-btn
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
86
|
+
outline
|
|
87
|
+
rounded
|
|
88
|
+
:label="$t('common.cancel')"
|
|
89
|
+
class="btn-min"
|
|
90
|
+
v-close-popup
|
|
54
91
|
/>
|
|
55
|
-
</div>
|
|
56
|
-
<q-card-actions>
|
|
57
92
|
<q-btn
|
|
58
|
-
data-cy="submit-login"
|
|
59
93
|
rounded
|
|
60
|
-
:label="$t('auth.login')"
|
|
61
94
|
color="primary"
|
|
62
|
-
:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
:disable="isSubmitBtnDisabled()"
|
|
95
|
+
:label="$t('common.send')"
|
|
96
|
+
class="btn-min"
|
|
97
|
+
@click="resetPassword"
|
|
66
98
|
/>
|
|
67
99
|
</q-card-actions>
|
|
68
|
-
</q-
|
|
69
|
-
</q-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<q-card style="min-width: 350px">
|
|
73
|
-
<q-card-section>
|
|
74
|
-
<p class="resetPasswordTitle">
|
|
75
|
-
{{ $t("auth.tapEmail") }}
|
|
76
|
-
</p>
|
|
77
|
-
</q-card-section>
|
|
78
|
-
|
|
79
|
-
<q-card-section class="q-pt-none">
|
|
80
|
-
<q-input
|
|
81
|
-
v-model="emailResetPassword"
|
|
82
|
-
dense
|
|
83
|
-
rounded
|
|
84
|
-
outlined
|
|
85
|
-
:placeholder="$t('auth.email')"
|
|
86
|
-
autofocus
|
|
87
|
-
/>
|
|
88
|
-
</q-card-section>
|
|
89
|
-
|
|
90
|
-
<q-card-actions align="right">
|
|
91
|
-
<q-btn
|
|
92
|
-
outline
|
|
93
|
-
rounded
|
|
94
|
-
:label="$t('common.cancel')"
|
|
95
|
-
class="btn-min"
|
|
96
|
-
v-close-popup
|
|
97
|
-
/>
|
|
98
|
-
<q-btn
|
|
99
|
-
rounded
|
|
100
|
-
color="primary"
|
|
101
|
-
:label="$t('common.send')"
|
|
102
|
-
class="btn-min"
|
|
103
|
-
@click="resetPassword"
|
|
104
|
-
/>
|
|
105
|
-
</q-card-actions>
|
|
106
|
-
</q-card>
|
|
107
|
-
</q-dialog>
|
|
108
|
-
</div>
|
|
109
|
-
</q-page>
|
|
110
|
-
</q-page-container>
|
|
100
|
+
</q-card>
|
|
101
|
+
</q-dialog>
|
|
102
|
+
</div>
|
|
103
|
+
</q-page>
|
|
111
104
|
</q-layout>
|
|
112
105
|
</template>
|
|
113
106
|
|
|
@@ -119,9 +112,20 @@ import { $api, $prompts, $router, $store } from "../../injects";
|
|
|
119
112
|
import { useQuasar } from "quasar";
|
|
120
113
|
import { useI18n } from "vue-i18n";
|
|
121
114
|
import { AxiosError, AxiosResponse } from "axios";
|
|
115
|
+
import prompts from "app/quasar.extensions.json";
|
|
116
|
+
|
|
117
|
+
interface HeadersInterface {
|
|
118
|
+
headers: {
|
|
119
|
+
"x-requested-roles"?: string
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
122
123
|
export default defineComponent({
|
|
123
124
|
name: "Auth",
|
|
124
125
|
setup() {
|
|
126
|
+
const {
|
|
127
|
+
"@sowell/auth": { X_REQUESTED_ROLES },
|
|
128
|
+
} = prompts;
|
|
125
129
|
const email = ref("");
|
|
126
130
|
const password = ref("");
|
|
127
131
|
const loading = ref(false);
|
|
@@ -184,8 +188,14 @@ export default defineComponent({
|
|
|
184
188
|
password: password.value,
|
|
185
189
|
},
|
|
186
190
|
};
|
|
191
|
+
const options: HeadersInterface = {
|
|
192
|
+
headers:{}
|
|
193
|
+
};
|
|
194
|
+
// @ts-ignore
|
|
195
|
+
let requestedRoles = window.Cypress ? window.Cypress.requestedRoles : X_REQUESTED_ROLES;
|
|
196
|
+
if (requestedRoles) options.headers["x-requested-roles"] = requestedRoles;
|
|
187
197
|
|
|
188
|
-
post(AUTH_SERVER_SIGNING_ROUTE, data)
|
|
198
|
+
post(AUTH_SERVER_SIGNING_ROUTE, data, options)
|
|
189
199
|
.then((response: AxiosResponse) => {
|
|
190
200
|
const token = response.data.jwt;
|
|
191
201
|
dispatch("token/updateRaw", token);
|
|
@@ -193,11 +203,31 @@ export default defineComponent({
|
|
|
193
203
|
})
|
|
194
204
|
.catch((error: AxiosError) => {
|
|
195
205
|
loading.value = false;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
206
|
+
switch (error.response?.status) {
|
|
207
|
+
case 403:
|
|
208
|
+
$q.notify({
|
|
209
|
+
message: t("auth.403"),
|
|
210
|
+
color: "negative",
|
|
211
|
+
position: "top",
|
|
212
|
+
});
|
|
213
|
+
console.log('403')
|
|
214
|
+
break;
|
|
215
|
+
case 404:
|
|
216
|
+
$q.notify({
|
|
217
|
+
message: t("auth.404"),
|
|
218
|
+
color: "negative",
|
|
219
|
+
position: "top",
|
|
220
|
+
});
|
|
221
|
+
console.log('404')
|
|
222
|
+
break;
|
|
223
|
+
default:
|
|
224
|
+
$q.notify({
|
|
225
|
+
message: t("auth.loginFailed"),
|
|
226
|
+
color: "negative",
|
|
227
|
+
position: "top",
|
|
228
|
+
});
|
|
229
|
+
console.log('default')
|
|
230
|
+
}
|
|
201
231
|
});
|
|
202
232
|
};
|
|
203
233
|
|
|
@@ -225,3 +255,11 @@ export default defineComponent({
|
|
|
225
255
|
},
|
|
226
256
|
});
|
|
227
257
|
</script>
|
|
258
|
+
|
|
259
|
+
<style scoped>
|
|
260
|
+
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&display=swap");
|
|
261
|
+
|
|
262
|
+
.q-page {
|
|
263
|
+
font-family: "Montserrat", sans-serif;
|
|
264
|
+
}
|
|
265
|
+
</style>
|
package/src/i18n/en-US/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export default {
|
|
|
14
14
|
emailSent: "Email sent, check your inbox",
|
|
15
15
|
tapEmail: "Please enter your email",
|
|
16
16
|
404: "No user found with the provided credentials",
|
|
17
|
+
403: "Insufficient rights, your account does not allow access to this interface",
|
|
17
18
|
},
|
|
18
19
|
common: {
|
|
19
20
|
register: "Save",
|
package/src/i18n/fr-FR/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export default {
|
|
|
14
14
|
emailSent: "Email envoyé, vérifier votre boite email",
|
|
15
15
|
tapEmail: "Entrer votre email",
|
|
16
16
|
404: "Aucun utilisateur trouvé avec les identifiants donnés",
|
|
17
|
+
403: "Droits insuffisants, votre compte ne permet pas d'acceder à cette interface",
|
|
17
18
|
},
|
|
18
19
|
common: {
|
|
19
20
|
register: "Enregistre",
|
package/src/prompts.js
CHANGED
|
@@ -82,9 +82,8 @@ module.exports = function () {
|
|
|
82
82
|
name: "VUEX_SET_EMAIL_MUTATION",
|
|
83
83
|
type: "input",
|
|
84
84
|
required: true,
|
|
85
|
-
message:
|
|
86
|
-
|
|
87
|
-
default: "auth/set_email_user"
|
|
85
|
+
message: "Vuex mutation to store user email when authenticated",
|
|
86
|
+
default: "auth/set_email_user",
|
|
88
87
|
},
|
|
89
88
|
{
|
|
90
89
|
name: "VUEX_SET_INFOS_USER_MUTATION",
|
|
@@ -107,5 +106,12 @@ module.exports = function () {
|
|
|
107
106
|
message: "Vuex getter user information",
|
|
108
107
|
default: "auth/get_infos_user",
|
|
109
108
|
},
|
|
109
|
+
{
|
|
110
|
+
name: "X_REQUESTED_ROLES",
|
|
111
|
+
type: "input",
|
|
112
|
+
required: true,
|
|
113
|
+
message: "Role required for the application",
|
|
114
|
+
default: "",
|
|
115
|
+
},
|
|
110
116
|
];
|
|
111
117
|
};
|