@sowell/quasar-app-extension-auth 0.4.8 → 0.5.0
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 +17 -14
- package/.github/workflows/main.yml +5 -5
- package/.github/workflows/publish.yml +1 -1
- package/package.json +4 -3
- package/src/boot/router-guards.ts +0 -1
- package/src/components/dialogs/sw-info-dialog.vue +7 -5
- package/src/components/pages/AdminAuth.vue +1 -6
- package/src/composables/auth.ts +2 -4
- package/src/index.js +21 -4
- package/src/injects/states.ts +1 -17
- package/src/routes/index.ts +21 -18
package/.eslintrc.js
CHANGED
|
@@ -2,26 +2,29 @@ module.exports = {
|
|
|
2
2
|
env: {
|
|
3
3
|
browser: true,
|
|
4
4
|
commonjs: true,
|
|
5
|
-
es2021: true
|
|
5
|
+
es2021: true,
|
|
6
6
|
},
|
|
7
7
|
extends: [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
"eslint:recommended",
|
|
9
|
+
"plugin:vue/vue3-strongly-recommended",
|
|
10
|
+
"prettier",
|
|
11
11
|
],
|
|
12
12
|
parserOptions: {
|
|
13
|
-
parser:
|
|
13
|
+
parser: "@typescript-eslint/parser",
|
|
14
14
|
ecmaVersion: 2018,
|
|
15
|
-
sourceType:
|
|
15
|
+
sourceType: "module",
|
|
16
16
|
},
|
|
17
|
-
plugins: [
|
|
17
|
+
plugins: ["vue"],
|
|
18
18
|
rules: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{ anonymous:
|
|
19
|
+
"comma-dangle": ["error", "only-multiline"],
|
|
20
|
+
"space-before-function-paren": [
|
|
21
|
+
"error",
|
|
22
|
+
{ anonymous: "always", named: "never", asyncArrow: "always" },
|
|
23
23
|
],
|
|
24
|
-
semi:
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
semi: "off",
|
|
25
|
+
"no-unreachable": "off",
|
|
26
|
+
"no-unused-vars": "off",
|
|
27
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
28
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
29
|
+
},
|
|
27
30
|
};
|
|
@@ -7,16 +7,16 @@ jobs:
|
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
9
|
- name: Checkout
|
|
10
|
-
uses: actions/checkout@
|
|
10
|
+
uses: actions/checkout@v4
|
|
11
11
|
- name: Nodejs
|
|
12
|
-
uses: actions/setup-node@
|
|
12
|
+
uses: actions/setup-node@v4
|
|
13
13
|
with:
|
|
14
|
-
node-version: '
|
|
14
|
+
node-version: '18'
|
|
15
15
|
cache: yarn
|
|
16
16
|
- run: yarn install
|
|
17
17
|
- run: yarn dep
|
|
18
18
|
- name: Cypress run
|
|
19
|
-
uses: cypress-io/github-action@
|
|
19
|
+
uses: cypress-io/github-action@v6
|
|
20
20
|
with:
|
|
21
21
|
working-directory: dev
|
|
22
|
-
command: yarn
|
|
22
|
+
command: yarn ci
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sowell/quasar-app-extension-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dep": "cd dev && yarn",
|
|
11
11
|
"test:link": "cd dev && yarn test:link",
|
|
12
12
|
"test:browser": "cd dev && yarn test:browser",
|
|
13
|
-
"test": "cd dev && yarn
|
|
13
|
+
"test": "cd dev && yarn ci"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [],
|
|
16
16
|
"author": "SoWell SAS",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"eslint-plugin-vue": "^7.0.0",
|
|
33
33
|
"jwt-decode": "^3.1.2",
|
|
34
34
|
"quasar": "^2.6.2",
|
|
35
|
-
"typescript": "^
|
|
35
|
+
"typescript": "^5.3.3"
|
|
36
36
|
},
|
|
37
37
|
"directories": {
|
|
38
38
|
"test": "test"
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@capacitor/core": "^4.6.2",
|
|
42
42
|
"@quasar/extras": "^1.13.4",
|
|
43
|
+
"@typescript-eslint/parser": "^6.19.1",
|
|
43
44
|
"axios": "^0.21.1",
|
|
44
45
|
"buffer": "^6.0.3",
|
|
45
46
|
"pinia": "^2.0.12",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
/>
|
|
15
15
|
</div>
|
|
16
16
|
<div class="row justify-center">
|
|
17
|
-
<img :src="
|
|
17
|
+
<img :src="imageSVG" />
|
|
18
18
|
</div>
|
|
19
19
|
</q-card-section>
|
|
20
20
|
|
|
@@ -52,7 +52,7 @@ import emailVerification from "../../assets/Email-sent.svg";
|
|
|
52
52
|
import { ionCloseOutline } from "@quasar/extras/ionicons-v5";
|
|
53
53
|
|
|
54
54
|
export default defineComponent({
|
|
55
|
-
name: "
|
|
55
|
+
name: "SwInfoDialog",
|
|
56
56
|
props: {
|
|
57
57
|
title: { type: String, required: true },
|
|
58
58
|
content: { type: String, required: true },
|
|
@@ -60,9 +60,9 @@ export default defineComponent({
|
|
|
60
60
|
passwordUpdated: { type: Boolean },
|
|
61
61
|
isOtp: { type: Boolean, default: false, required: false },
|
|
62
62
|
},
|
|
63
|
-
|
|
63
|
+
emits: ["goToLoginPage"],
|
|
64
64
|
setup(props: any) {
|
|
65
|
-
const
|
|
65
|
+
const imageSVG = computed(() => {
|
|
66
66
|
switch (props.image) {
|
|
67
67
|
case "userNotFound":
|
|
68
68
|
return userNotFound;
|
|
@@ -72,9 +72,11 @@ export default defineComponent({
|
|
|
72
72
|
|
|
73
73
|
case "emailVerification":
|
|
74
74
|
return emailVerification;
|
|
75
|
+
default:
|
|
76
|
+
return "";
|
|
75
77
|
}
|
|
76
78
|
});
|
|
77
|
-
return {
|
|
79
|
+
return { imageSVG, icons: { ionCloseOutline } };
|
|
78
80
|
},
|
|
79
81
|
});
|
|
80
82
|
</script>
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
:title="infoDialog.title"
|
|
100
100
|
:content="infoDialog.content"
|
|
101
101
|
:image="infoDialog.image"
|
|
102
|
-
:
|
|
102
|
+
:is-otp="true"
|
|
103
103
|
>
|
|
104
104
|
<q-btn
|
|
105
105
|
v-if="requestedOtp"
|
|
@@ -128,11 +128,6 @@ import WebSendEmail from "../dialogs/WebSendEmail.vue";
|
|
|
128
128
|
|
|
129
129
|
import { useAuth } from "composables/auth";
|
|
130
130
|
|
|
131
|
-
interface HeadersInterface {
|
|
132
|
-
headers: {
|
|
133
|
-
"x-requested-roles"?: string;
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
131
|
export default defineComponent({
|
|
137
132
|
name: "Auth",
|
|
138
133
|
components: { WebSendEmail, SwInfoDialog },
|
package/src/composables/auth.ts
CHANGED
|
@@ -65,7 +65,7 @@ export function useAuth() {
|
|
|
65
65
|
const validations = ref({
|
|
66
66
|
email: [
|
|
67
67
|
(val: string) => {
|
|
68
|
-
errorEmailMessage.value =
|
|
68
|
+
errorEmailMessage.value = val ? "" : t("auth.emailPresenceError");
|
|
69
69
|
return !!val || t("auth.emailPresenceError");
|
|
70
70
|
},
|
|
71
71
|
(val: string) => {
|
|
@@ -77,9 +77,7 @@ export function useAuth() {
|
|
|
77
77
|
],
|
|
78
78
|
password: [
|
|
79
79
|
(val: string) => {
|
|
80
|
-
errorPasswordMessage.value =
|
|
81
|
-
? ""
|
|
82
|
-
: t("auth.passwordPresenceError");
|
|
80
|
+
errorPasswordMessage.value = val ? "" : t("auth.passwordPresenceError");
|
|
83
81
|
return !!val || t("auth.passwordPresenceError");
|
|
84
82
|
},
|
|
85
83
|
],
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const path = require("path");
|
|
3
|
-
function extendConf(conf) {
|
|
3
|
+
function extendConf(conf, api) {
|
|
4
4
|
const requiredPlugins = ["Notify"];
|
|
5
5
|
|
|
6
6
|
requiredPlugins.forEach((plugin) => {
|
|
@@ -20,7 +20,9 @@ function extendConf(conf) {
|
|
|
20
20
|
);
|
|
21
21
|
conf.boot.push("~@sowell/quasar-app-extension-auth/src/boot/axios.ts");
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
if (api.hasWebpack) {
|
|
24
|
+
conf.build.transpileDependencies.push(/quasar-app-extension-auth[\\/]src/);
|
|
25
|
+
}
|
|
24
26
|
|
|
25
27
|
console.log("Boot sowell auth");
|
|
26
28
|
}
|
|
@@ -34,9 +36,24 @@ const chainWebpack = (ctx, chain) => {
|
|
|
34
36
|
path.resolve(__dirname, "./composables")
|
|
35
37
|
);
|
|
36
38
|
};
|
|
39
|
+
|
|
40
|
+
const aliasVite = (viteConf) => {
|
|
41
|
+
viteConf.define.global = {};
|
|
42
|
+
viteConf.resolve.alias = {
|
|
43
|
+
...viteConf.resolve.alias,
|
|
44
|
+
"@sowell/auth": path.resolve(__dirname, "./components"),
|
|
45
|
+
composables: path.resolve(__dirname, "./composables"),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
37
49
|
module.exports = function (api) {
|
|
38
50
|
api.compatibleWith("quasar", "^2.0.0");
|
|
39
|
-
api.
|
|
40
|
-
|
|
51
|
+
if (api.hasVite === true) {
|
|
52
|
+
api.compatibleWith("@quasar/app-vite", "^1.3.0");
|
|
53
|
+
api.extendViteConf(aliasVite);
|
|
54
|
+
} else {
|
|
55
|
+
api.compatibleWith("@quasar/app", "^3.0.0");
|
|
56
|
+
api.chainWebpack((chain) => chainWebpack(api.ctx, chain));
|
|
57
|
+
}
|
|
41
58
|
api.extendQuasarConf(extendConf);
|
|
42
59
|
};
|
package/src/injects/states.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { inject } from "vue";
|
|
2
2
|
import { Store } from "pinia";
|
|
3
|
-
import { AxiosResponse } from "axios";
|
|
4
3
|
import { $prompts } from "../injects";
|
|
5
4
|
|
|
6
5
|
export interface AuthStatePayload {
|
|
@@ -72,22 +71,7 @@ export interface ResetPasswordPayload {
|
|
|
72
71
|
};
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
export const useAuthState = ()
|
|
76
|
-
"auth",
|
|
77
|
-
AuthState,
|
|
78
|
-
{
|
|
79
|
-
getIsValid(state: AuthState): boolean;
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
signin(
|
|
83
|
-
data: SignInPayload,
|
|
84
|
-
options: RequestOptions
|
|
85
|
-
): Promise<AxiosResponse>;
|
|
86
|
-
msalSignin(): Promise<AxiosResponse>;
|
|
87
|
-
resetPassword(data: ResetPasswordPayload): Promise<AxiosResponse>;
|
|
88
|
-
updateRaw(value: string): void;
|
|
89
|
-
}
|
|
90
|
-
> => {
|
|
74
|
+
export const useAuthState = () => {
|
|
91
75
|
const authState = inject<Store<"auth", AuthState>>("authState");
|
|
92
76
|
if (authState == undefined) {
|
|
93
77
|
throw Error("Could not inject authState");
|
package/src/routes/index.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
//@ts-ignore
|
|
2
2
|
import prompts from "app/quasar.extensions.json";
|
|
3
3
|
import { RouteRecordRaw } from "vue-router";
|
|
4
|
+
import AdminAuth from "../components/pages/AdminAuth.vue";
|
|
5
|
+
import WebAuth from "../components/pages/WebAuth.vue";
|
|
6
|
+
import WebResetPassword from "../components/pages/WebResetPassword.vue";
|
|
7
|
+
import ResetPaswword from "../components/pages/ResetPassword.vue";
|
|
8
|
+
|
|
9
|
+
import Auth from "../components/pages/Auth.vue";
|
|
10
|
+
import AuthReporter from "../components/pages/AuthReporter.vue";
|
|
4
11
|
|
|
5
12
|
const {
|
|
6
13
|
"@sowell/auth": {
|
|
@@ -20,54 +27,50 @@ let authPage = "";
|
|
|
20
27
|
|
|
21
28
|
switch (UI_PAGE) {
|
|
22
29
|
case "mobile_clean":
|
|
23
|
-
authPage =
|
|
30
|
+
authPage = Auth;
|
|
24
31
|
break;
|
|
25
32
|
case "reporter":
|
|
26
|
-
authPage =
|
|
33
|
+
authPage = AuthReporter;
|
|
27
34
|
break;
|
|
28
35
|
case "admin":
|
|
29
|
-
authPage =
|
|
36
|
+
authPage = AdminAuth;
|
|
30
37
|
break;
|
|
31
38
|
default:
|
|
32
|
-
authPage =
|
|
39
|
+
authPage = Auth;
|
|
33
40
|
break;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
|
-
const loginPage = (X_REQUESTED_ROLES: string)
|
|
43
|
+
const loginPage = (X_REQUESTED_ROLES: string) => {
|
|
37
44
|
return X_REQUESTED_ROLES === "admin"
|
|
38
|
-
?
|
|
45
|
+
? AdminAuth
|
|
39
46
|
: webAuthRoles.includes(X_REQUESTED_ROLES)
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
? WebAuth
|
|
48
|
+
: authPage;
|
|
42
49
|
};
|
|
43
50
|
|
|
44
|
-
const isInRoles = (X_REQUESTED_ROLES: string)
|
|
51
|
+
const isInRoles = (X_REQUESTED_ROLES: string) => {
|
|
45
52
|
return webAuthRoles.includes(X_REQUESTED_ROLES) ||
|
|
46
53
|
AdminAuthRoles.includes(X_REQUESTED_ROLES)
|
|
47
|
-
?
|
|
48
|
-
:
|
|
54
|
+
? WebResetPassword
|
|
55
|
+
: ResetPaswword;
|
|
49
56
|
};
|
|
50
57
|
|
|
51
58
|
const routes: RouteRecordRaw[] = [
|
|
52
59
|
{
|
|
53
60
|
path: LOCAL_LOGIN_ROUTE,
|
|
54
|
-
component: () =>
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
import(`@sowell/auth/pages/${loginPage(X_REQUESTED_ROLES)}`),
|
|
61
|
+
component: () => loginPage(X_REQUESTED_ROLES),
|
|
57
62
|
},
|
|
58
63
|
{
|
|
59
64
|
path: LOCAL_UPDATE_PASSWORD_ROUTE,
|
|
60
65
|
name: "update_password",
|
|
61
|
-
component: () =>
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
import(`@sowell/auth/pages/${isInRoles(X_REQUESTED_ROLES)}`),
|
|
66
|
+
component: () => isInRoles(X_REQUESTED_ROLES),
|
|
64
67
|
},
|
|
65
68
|
{
|
|
66
69
|
path: LOCAL_OTP_ROUTE,
|
|
67
70
|
name: "otp_validation",
|
|
68
71
|
component: () =>
|
|
69
72
|
// @ts-ignore
|
|
70
|
-
import("
|
|
73
|
+
import("../components/pages/OtpValidation.vue"),
|
|
71
74
|
},
|
|
72
75
|
];
|
|
73
76
|
|