@sowell/quasar-app-extension-auth 0.3.22 → 0.3.23
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 +2 -1
- package/src/composables/auth.ts +38 -5
- package/src/injects/prompts.ts +1 -0
- package/src/injects/states.ts +12 -3
- package/src/prompts.js +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sowell/quasar-app-extension-auth",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.23",
|
|
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",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"test": "test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@capacitor/core": "^4.6.2",
|
|
41
42
|
"@quasar/extras": "^1.13.4",
|
|
42
43
|
"axios": "^0.21.1",
|
|
43
44
|
"buffer": "^6.0.3",
|
package/src/composables/auth.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, onMounted } from "vue";
|
|
1
|
+
import { ref, onMounted, inject } from "vue";
|
|
2
2
|
import isEmail from "validator/es/lib/isEmail";
|
|
3
3
|
import { useI18n } from "vue-i18n";
|
|
4
4
|
import {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "@quasar/extras/ionicons-v5";
|
|
12
12
|
import { Platform } from "quasar";
|
|
13
13
|
|
|
14
|
-
import { $prompts, $router, useAuthState } from "../injects";
|
|
14
|
+
import { $prompts, $router, SignInPayload, useAuthState } from "../injects";
|
|
15
15
|
|
|
16
16
|
interface HeadersInterface {
|
|
17
17
|
headers: {
|
|
@@ -21,6 +21,13 @@ interface HeadersInterface {
|
|
|
21
21
|
|
|
22
22
|
export function useAuth() {
|
|
23
23
|
const authState = useAuthState();
|
|
24
|
+
const device = inject("Device")
|
|
25
|
+
let deviceInfos = {
|
|
26
|
+
cleanManufacturer: "",
|
|
27
|
+
cleanModel: "",
|
|
28
|
+
cleanPlatform: "",
|
|
29
|
+
cleanVersion: ""
|
|
30
|
+
}
|
|
24
31
|
|
|
25
32
|
const { t } = useI18n();
|
|
26
33
|
const {
|
|
@@ -31,6 +38,7 @@ export function useAuth() {
|
|
|
31
38
|
WELCOME_SUBTITLE,
|
|
32
39
|
IS_OTP,
|
|
33
40
|
LOCAL_OTP_ROUTE,
|
|
41
|
+
APP_VERSION
|
|
34
42
|
} = $prompts();
|
|
35
43
|
const { push, replace } = $router();
|
|
36
44
|
|
|
@@ -71,20 +79,44 @@ export function useAuth() {
|
|
|
71
79
|
forgottenPassword.value = true;
|
|
72
80
|
};
|
|
73
81
|
|
|
82
|
+
const deviceInfo = async () => {
|
|
83
|
+
if (device) {
|
|
84
|
+
const info = await device.getInfo();
|
|
85
|
+
deviceInfos = {
|
|
86
|
+
cleanManufacturer: info.manufacturer,
|
|
87
|
+
cleanModel: info.model,
|
|
88
|
+
cleanPlatform: info.platform,
|
|
89
|
+
cleanVersion: info.osVersion
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
74
94
|
const onSubmit = async () => {
|
|
75
95
|
loading.value = true;
|
|
76
|
-
const data = {
|
|
96
|
+
const data: SignInPayload = {
|
|
77
97
|
auth: {
|
|
78
98
|
email: email.value,
|
|
79
99
|
password: password.value,
|
|
80
100
|
},
|
|
81
101
|
};
|
|
102
|
+
if (device) {
|
|
103
|
+
data.device = {
|
|
104
|
+
cleanManufacturer: deviceInfos.cleanManufacturer,
|
|
105
|
+
cleanModel: deviceInfos.cleanModel,
|
|
106
|
+
cleanPlatform: deviceInfos.cleanPlatform,
|
|
107
|
+
cleanVersion: deviceInfos.cleanVersion,
|
|
108
|
+
},
|
|
109
|
+
data.app = {
|
|
110
|
+
cleanVersionNumber: APP_VERSION
|
|
111
|
+
}
|
|
112
|
+
};
|
|
82
113
|
const options: HeadersInterface = {
|
|
83
114
|
headers: {},
|
|
84
115
|
};
|
|
85
116
|
// @ts-ignore
|
|
86
117
|
let requestedRoles = window.Cypress
|
|
87
|
-
?
|
|
118
|
+
? // @ts-ignore
|
|
119
|
+
window.Cypress.requestedRoles
|
|
88
120
|
: X_REQUESTED_ROLES;
|
|
89
121
|
if (requestedRoles) options.headers["x-requested-roles"] = requestedRoles;
|
|
90
122
|
|
|
@@ -125,7 +157,8 @@ export function useAuth() {
|
|
|
125
157
|
push(LOCAL_OTP_ROUTE);
|
|
126
158
|
};
|
|
127
159
|
|
|
128
|
-
onMounted(() => {
|
|
160
|
+
onMounted(async () => {
|
|
161
|
+
await deviceInfo()
|
|
129
162
|
if (authState.raw) {
|
|
130
163
|
replace(LOCAL_SUCCESS_REDIRECTION_ROUTE);
|
|
131
164
|
}
|
package/src/injects/prompts.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface PromptsInterface {
|
|
|
22
22
|
LOCAL_OTP_ROUTE: string;
|
|
23
23
|
AUTH_SERVER_VERIFY_OTP: string;
|
|
24
24
|
UI_PAGE: string;
|
|
25
|
+
APP_VERSION: string;
|
|
25
26
|
}
|
|
26
27
|
export const $prompts = (): PromptsInterface => {
|
|
27
28
|
const $prompts = inject<Record<"@sowell/auth", PromptsInterface>>("$prompts");
|
package/src/injects/states.ts
CHANGED
|
@@ -23,9 +23,18 @@ export interface RequestOptions {
|
|
|
23
23
|
|
|
24
24
|
export interface SignInPayload {
|
|
25
25
|
auth: {
|
|
26
|
-
email: string
|
|
27
|
-
password: string
|
|
28
|
-
}
|
|
26
|
+
email: string
|
|
27
|
+
password: string
|
|
28
|
+
}
|
|
29
|
+
device?: {
|
|
30
|
+
cleanManufacturer: string
|
|
31
|
+
cleanModel: string
|
|
32
|
+
cleanPlatform: string,
|
|
33
|
+
cleanVersion: string
|
|
34
|
+
}
|
|
35
|
+
app?: {
|
|
36
|
+
cleanVersionNumber: string
|
|
37
|
+
}
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
export interface ResetPasswordPayload {
|
package/src/prompts.js
CHANGED
|
@@ -169,5 +169,11 @@ module.exports = function () {
|
|
|
169
169
|
message: "API endpoint to send OTP (without host)",
|
|
170
170
|
default: "/sign-in-otp",
|
|
171
171
|
},
|
|
172
|
+
{
|
|
173
|
+
name: "APP_VERSION",
|
|
174
|
+
required: true,
|
|
175
|
+
message: "Version de l'application",
|
|
176
|
+
default: "",
|
|
177
|
+
},
|
|
172
178
|
];
|
|
173
179
|
};
|