@ozdao/prometheus-framework 0.2.22 → 0.2.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth.server.js +10 -3
- package/dist/auth.server.mjs +10 -3
- package/dist/community.server.js +1 -1
- package/dist/community.server.mjs +1 -1
- package/dist/events.server.js +1 -1
- package/dist/events.server.mjs +1 -1
- package/dist/files.server.js +1 -1
- package/dist/files.server.mjs +1 -1
- package/dist/gallery.server.js +1 -1
- package/dist/gallery.server.mjs +1 -1
- package/dist/globals.server.js +1 -1
- package/dist/globals.server.mjs +1 -1
- package/dist/index-05aa7cae.js +213 -0
- package/dist/index-d5066b82.mjs +214 -0
- package/dist/mailing-02321795.js +49 -0
- package/dist/mailing-eb3bd084.mjs +50 -0
- package/dist/middlewares.server.js +1 -1
- package/dist/middlewares.server.mjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +29 -25
- package/dist/prometheus-framework/src/modules/auth/store/twofa.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/store/twofa.js +12 -11
- package/dist/reports.server.js +1 -1
- package/dist/reports.server.mjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/modules/auth/components/pages/EnterCode.vue +81 -62
- package/src/modules/auth/routes/twofa.routes.js +9 -1
- package/src/modules/auth/store/twofa.js +4 -1
- package/src/modules/globals/utils/mailing.js +1 -1
- package/src/modules/middlewares/server/verifyUser.js +1 -0
@@ -1,9 +1,11 @@
|
|
1
1
|
<template>
|
2
2
|
<section class="t-center pd-medium">
|
3
3
|
<!-- <img src="@/assets/images/icons/message1.png" class="i-extra mn-b-small"> -->
|
4
|
+
|
4
5
|
<h3 class="mn-b-medium">
|
5
6
|
{{ t('verifyNumberTitle') }}
|
6
7
|
</h3>
|
8
|
+
|
7
9
|
<p class="mn-b-big t-transp">{{ t('instructions') }}</p>
|
8
10
|
|
9
11
|
<div class="w-100 mn-b-big flex-nowrap flex">
|
@@ -26,12 +28,33 @@
|
|
26
28
|
@keydown="($event) => onKeyDown($event, 1)"
|
27
29
|
class="w-100 h1 pd-small t-center bg-grey radius-small mn-r-small"
|
28
30
|
>
|
29
|
-
<input
|
30
|
-
|
31
|
+
<input
|
32
|
+
type="number"
|
33
|
+
v-model="state.digits[2]"
|
34
|
+
maxlength="1"
|
35
|
+
@input="onInput(2)"
|
36
|
+
@paste="($event) => onPaste($event, 2)"
|
37
|
+
@keydown="($event) => onKeyDown($event, 2)"
|
38
|
+
class="w-100 h1 pd-small t-center bg-grey radius-small mn-r-small"
|
39
|
+
>
|
40
|
+
<input
|
41
|
+
type="number"
|
42
|
+
v-model="state.digits[3]"
|
43
|
+
maxlength="1"
|
44
|
+
@input="onInput(3)"
|
45
|
+
@paste="($event) => onPaste($event, 3)"
|
46
|
+
@keydown="($event) => onKeyDown($event, 3)"
|
47
|
+
class="w-100 h1 pd-small t-center bg-grey radius-small"
|
48
|
+
>
|
31
49
|
</div>
|
32
50
|
|
33
|
-
<a v-if="resendTimer < 1" @click="sendAgain" class="t-blue">
|
34
|
-
|
51
|
+
<a v-if="resendTimer < 1" @click="sendAgain" class="t-blue">
|
52
|
+
{{ t('resendCode') }}
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<span v-else>
|
56
|
+
{{resendTimer}} {{ t('secondsResend') }}
|
57
|
+
</span>
|
35
58
|
</section>
|
36
59
|
</template>
|
37
60
|
|
@@ -63,9 +86,6 @@
|
|
63
86
|
watch(
|
64
87
|
() => state.digits[0],
|
65
88
|
(newVal) => {
|
66
|
-
console.log(String(newVal));
|
67
|
-
console.log(String(newVal).length);
|
68
|
-
|
69
89
|
if (newVal && String(newVal).length > 1) {
|
70
90
|
let newValArray = String(newVal).split('');
|
71
91
|
console.log(newValArray);
|
@@ -91,20 +111,24 @@
|
|
91
111
|
|
92
112
|
async function sendAgain () {
|
93
113
|
try {
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
114
|
+
await twofa.sendCode(
|
115
|
+
auth.state.user,
|
116
|
+
route.query.method,
|
117
|
+
route.query.type,
|
118
|
+
)
|
119
|
+
|
120
|
+
resendTimer.value = 30;
|
121
|
+
|
122
|
+
// Start the timer using `setInterval()`
|
123
|
+
const timer = setInterval(() => {
|
124
|
+
if (resendTimer.value > 0) {
|
125
|
+
// Decrement the timer by 1 second
|
126
|
+
resendTimer.value -= 1;
|
127
|
+
} else {
|
128
|
+
// Stop the timer when it reaches 0 seconds
|
129
|
+
clearInterval(timer);
|
130
|
+
}
|
131
|
+
}, 1000);
|
108
132
|
} catch (error) {
|
109
133
|
setError({ response: {data: { errorCode: "CODE_NOT_SENT"}}})
|
110
134
|
}
|
@@ -141,44 +165,39 @@
|
|
141
165
|
// };
|
142
166
|
|
143
167
|
const onInput = (index) => {
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
};
|
179
|
-
|
180
|
-
</script>
|
181
|
-
|
182
|
-
<style lang="scss">
|
183
|
-
|
184
|
-
</style>
|
168
|
+
const inputs = document.querySelectorAll('input');
|
169
|
+
const nextInput = inputs[index + 1];
|
170
|
+
const prevInput = index > 0 ? inputs[index - 1] : null;
|
171
|
+
|
172
|
+
// Переход на следующий инпут
|
173
|
+
if (state.digits[index] !== '' && state.digits[index] !== null && state.digits[index] !== undefined && index < 4) {
|
174
|
+
if (index < 3) nextInput.focus();
|
175
|
+
else firstInput.value.focus();
|
176
|
+
}
|
177
|
+
|
178
|
+
// Переход на предыдущий инпут при удалении
|
179
|
+
if ((state.digits[index] === null || state.digits[index] === undefined || state.digits[index] === '') && index > 0) {
|
180
|
+
prevInput.focus();
|
181
|
+
}
|
182
|
+
|
183
|
+
// Проверка введенного кода
|
184
|
+
if (state.digits.every(digit => digit !== '')) {
|
185
|
+
const enteredCode = state.digits.join('');
|
186
|
+
const correctCode = twofa.state.code.code.toString();
|
187
|
+
|
188
|
+
if (enteredCode === correctCode) {
|
189
|
+
twofa.state.code.isValid = true;
|
190
|
+
|
191
|
+
router.push({
|
192
|
+
path: '/auth/enter-password',
|
193
|
+
query: { type: twofa.state.code.type, method: route.query.method }
|
194
|
+
});
|
195
|
+
|
196
|
+
} else {
|
197
|
+
setError({ response: {data: { errorCode: "WRONG_CODE"}}})
|
198
|
+
firstInput.value.focus()
|
199
|
+
state.digits = ['', '', '', ''];
|
200
|
+
}
|
201
|
+
}
|
202
|
+
};
|
203
|
+
</script>
|
@@ -5,7 +5,7 @@ const middlewareFactory = require('@pf/src/modules/middlewares/server');
|
|
5
5
|
// Routes
|
6
6
|
module.exports = function(app, db) {
|
7
7
|
const controller = controllerFactory(db);
|
8
|
-
const { verifySignUp } = middlewareFactory(db);
|
8
|
+
const { verifySignUp, verifyUser } = middlewareFactory(db);
|
9
9
|
|
10
10
|
app.use(function(req, res, next) {
|
11
11
|
res.header(
|
@@ -23,4 +23,12 @@ module.exports = function(app, db) {
|
|
23
23
|
],
|
24
24
|
controller.sendcode
|
25
25
|
);
|
26
|
+
|
27
|
+
app.post(
|
28
|
+
"/api/twofa/sendcodereset",
|
29
|
+
[
|
30
|
+
verifyUser.checkUserExist
|
31
|
+
],
|
32
|
+
controller.sendcode
|
33
|
+
);
|
26
34
|
};
|
@@ -19,8 +19,11 @@ const state = reactive({
|
|
19
19
|
});
|
20
20
|
|
21
21
|
async function sendCode (user, method, type) {
|
22
|
+
let api = '/api/twofa/sendcode'
|
22
23
|
|
23
|
-
|
24
|
+
if (method === 'reset-password') api = '/api/twofa/sendcodereset'
|
25
|
+
|
26
|
+
return await $axios.post(api, {
|
24
27
|
phone: user.phone.number,
|
25
28
|
email: user.email,
|
26
29
|
method: method,
|
@@ -32,7 +32,7 @@ async function sendEmail(to, subject, text) {
|
|
32
32
|
}
|
33
33
|
|
34
34
|
async function sendSms(phone, message) {
|
35
|
-
const sessionUrl = `https://api.sms.to/sms/send?api_key=${process.env.SMS_API_KEY}&bypass_optout=true&to=${phone}&message=${encodeURIComponent(message)}&sender_id=${process.env.APP_NAME}`;
|
35
|
+
const sessionUrl = `https://api.sms.to/sms/send?api_key=${process.env.SMS_API_KEY}&bypass_optout=true&to=${phone}&message=${encodeURIComponent(message)}&sender_id=${encodeURIComponent(process.env.APP_NAME)}`;
|
36
36
|
|
37
37
|
console.log(`Phone:${phone} message:${message}`);
|
38
38
|
|