nodebb-plugin-phone-verification 3.0.0 → 3.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/library.js +62 -5
- package/package.json +1 -1
- package/plugin.json +1 -1
package/library.js
CHANGED
|
@@ -567,6 +567,7 @@ plugin.init = async function (params) {
|
|
|
567
567
|
router.get('/api/admin/plugins/phone-verification/settings', middleware.admin.checkPrivileges, plugin.apiAdminGetSettings);
|
|
568
568
|
router.post('/api/admin/plugins/phone-verification/settings', middleware.admin.checkPrivileges, middleware.applyCSRF, plugin.apiAdminSaveSettings);
|
|
569
569
|
router.post('/api/admin/plugins/phone-verification/test-call', middleware.admin.checkPrivileges, middleware.applyCSRF, plugin.apiAdminTestCall);
|
|
570
|
+
router.post('/api/admin/plugins/phone-verification/test-user-call', middleware.admin.checkPrivileges, middleware.applyCSRF, plugin.apiAdminTestUserCall);
|
|
570
571
|
router.post('/api/admin/plugins/phone-verification/refresh-token', middleware.admin.checkPrivileges, middleware.applyCSRF, plugin.apiAdminRefreshToken);
|
|
571
572
|
};
|
|
572
573
|
plugin.apiCheckStatus = async function (req, res) {
|
|
@@ -652,6 +653,41 @@ plugin.apiAdminTestCall = async function (req, res) {
|
|
|
652
653
|
} catch (err) { res.json({ success: false }); }
|
|
653
654
|
};
|
|
654
655
|
|
|
656
|
+
plugin.apiAdminTestUserCall = async function (req, res) {
|
|
657
|
+
try {
|
|
658
|
+
const { phoneNumber } = req.body;
|
|
659
|
+
if (!phoneNumber) return res.json({ success: false, message: 'חסר טלפון' });
|
|
660
|
+
|
|
661
|
+
const settings = await plugin.getSettings();
|
|
662
|
+
if (!settings.userCallEnabled) {
|
|
663
|
+
return res.json({ success: false, message: 'אימות בשיחה יזומה אינו פעיל' });
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
const clean = plugin.normalizePhone(phoneNumber);
|
|
667
|
+
if (!plugin.validatePhoneNumber(clean)) {
|
|
668
|
+
return res.json({ success: false, message: 'מספר טלפון לא תקין' });
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// יצירת קוד אימות זמני לבדיקה
|
|
672
|
+
const code = plugin.generateNumericCode();
|
|
673
|
+
const saveResult = await plugin.saveVerificationCode(clean, code, { storePlain: true });
|
|
674
|
+
|
|
675
|
+
if (!saveResult.success) {
|
|
676
|
+
return res.json({ success: false, message: 'שגיאה בשמירת קוד האימות' });
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
res.json({
|
|
680
|
+
success: true,
|
|
681
|
+
code: code,
|
|
682
|
+
phoneNumber: settings.userCallNumber || 'לא הוגדר',
|
|
683
|
+
message: 'קוד אימות נוצר בהצלחה לבדיקה'
|
|
684
|
+
});
|
|
685
|
+
} catch (err) {
|
|
686
|
+
console.error(err);
|
|
687
|
+
res.json({ success: false, message: 'שגיאה ביצירת קוד האימות' });
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
|
|
655
691
|
plugin.apiSendCode = async function (req, res) {
|
|
656
692
|
try {
|
|
657
693
|
const { phoneNumber } = req.body;
|
|
@@ -781,23 +817,44 @@ plugin.apiInboundCall = async function (req, res) {
|
|
|
781
817
|
const phone = req.query.ApiPhone;
|
|
782
818
|
|
|
783
819
|
if (!token || token !== settings.callApiToken) {
|
|
784
|
-
|
|
820
|
+
const errorPayload = 'read=t-שגיאת הרשאה - הטוקן אינו תקין. אנא פנו למנהל המערכת. לבדיקה חוזרת הַקִּישׁוּ 1=MOP,,1,1,15,NO,,,,1,3,OK,,,no';
|
|
821
|
+
res.set('Content-Type', 'text/plain; charset=utf-8');
|
|
822
|
+
return res.status(403).send(errorPayload);
|
|
785
823
|
}
|
|
786
824
|
if (!phone || !plugin.validatePhoneNumber(phone)) {
|
|
787
|
-
|
|
825
|
+
const errorPayload = 'read=t-מספר הטלפון אינו תקין או חסר. אנא פנו למנהל המערכת. לבדיקה חוזרת הַקִּישׁוּ 1=MOP,,1,1,15,NO,,,,1,3,OK,,,no';
|
|
826
|
+
res.set('Content-Type', 'text/plain; charset=utf-8');
|
|
827
|
+
return res.status(400).send(errorPayload);
|
|
788
828
|
}
|
|
789
829
|
|
|
790
830
|
const pending = await plugin.getPendingPlainCode(phone);
|
|
791
831
|
if (!pending.success) {
|
|
792
|
-
|
|
832
|
+
let errorMessage = 'קוד האימות לא נמצא או פג תוקפו';
|
|
833
|
+
|
|
834
|
+
// הודעות ספציפיות לפי סוג השגיאה
|
|
835
|
+
if (pending.error === 'CODE_EXPIRED') {
|
|
836
|
+
errorMessage = 'פג תוקף קוד האימות';
|
|
837
|
+
} else if (pending.error === 'PHONE_BLOCKED') {
|
|
838
|
+
errorMessage = 'המספר חסום זמנית';
|
|
839
|
+
} else if (pending.error === 'CODE_UNAVAILABLE') {
|
|
840
|
+
errorMessage = 'הקוד אינו זמין כרגע';
|
|
841
|
+
} else if (pending.error === 'DB_ERROR') {
|
|
842
|
+
errorMessage = 'שגיאה במסד הנתונים';
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
const errorPayload = `read=t-${errorMessage}. אנא פנו למנהל המערכת. לבדיקה חוזרת הַקִּישׁוּ 1=MOP,,1,1,15,NO,,,,1,3,OK,,,no`;
|
|
846
|
+
res.set('Content-Type', 'text/plain; charset=utf-8');
|
|
847
|
+
return res.status(404).send(errorPayload);
|
|
793
848
|
}
|
|
794
849
|
|
|
795
850
|
const code = pending.code;
|
|
796
|
-
const payload = `read=t-הקוד שלכם החד פעמי הוא.d-${code}.t-לשמיעה חוזרת הַקִּישׁוּ1=MOP,,1,1,15,NO,,,,1,3,OK,,,no`;
|
|
851
|
+
const payload = `read=t-הקוד שלכם החד פעמי הוא.d-${code}.t-לשמיעה חוזרת הַקִּישׁוּ 1=MOP,,1,1,15,NO,,,,1,3,OK,,,no`;
|
|
797
852
|
res.set('Content-Type', 'text/plain; charset=utf-8');
|
|
798
853
|
res.send(payload);
|
|
799
854
|
} catch (err) {
|
|
800
|
-
|
|
855
|
+
const errorPayload = 'read=t-שגיאה כללית במערכת. אנא פנו למנהל המערכת. לבדיקה חוזרת הַקִּישׁוּ 1=MOP,,1,1,15,NO,,,,1,3,OK,,,no';
|
|
856
|
+
res.set('Content-Type', 'text/plain; charset=utf-8');
|
|
857
|
+
res.status(500).send(errorPayload);
|
|
801
858
|
}
|
|
802
859
|
};
|
|
803
860
|
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "nodebb-plugin-phone-verification",
|
|
3
3
|
"name": "Phone Verification",
|
|
4
4
|
"description": "אימות מספר טלפון נייד בתהליך ההרשמה לפורום ובפרופיל המשתמש",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.1",
|
|
6
6
|
"library": "./library.js",
|
|
7
7
|
"hooks": [
|
|
8
8
|
{ "hook": "filter:register.check", "method": "checkRegistration" },
|