Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions Modules/Account/moduleSrc/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,23 +615,6 @@ bool IMPL_REST_GET_OR_POST(Account, logout, (
return true;
}

bool IMPL_REST_GET_OR_POST(Account, createForgotPasswordLink, (
APICALLBOOM_TYPE_JWT_ANONYMOUSE_IMPL &APICALLBOOM_PARAM,
QString _emailOrMobile
)) {
Authorization::validateIPAddress(APICALLBOOM_PARAM, APICALLBOOM_PARAM.getIP());

QString Type = PhoneHelper::ValidateAndNormalizeEmailOrPhoneNumber(_emailOrMobile);

this->callSP(APICALLBOOM_PARAM,
"spForgotPass_Request", {
{ "iLogin", _emailOrMobile },
{ "iBy", Type },
});

return true; //(Type == "E" ? "email" : "mobile");
}

bool IMPL_REST_GET_OR_POST(Account, changePass, (
APICALLBOOM_TYPE_JWT_USER_IMPL &APICALLBOOM_PARAM,
TAPI::MD5_t _newPass,
Expand All @@ -655,6 +638,23 @@ bool IMPL_REST_GET_OR_POST(Account, changePass, (
return true;
}

bool IMPL_REST_GET_OR_POST(Account, createForgotPasswordLink, (
APICALLBOOM_TYPE_JWT_ANONYMOUSE_IMPL &APICALLBOOM_PARAM,
QString _emailOrMobile
)) {
Authorization::validateIPAddress(APICALLBOOM_PARAM, APICALLBOOM_PARAM.getIP());

QString Type = PhoneHelper::ValidateAndNormalizeEmailOrPhoneNumber(_emailOrMobile);

this->callSP(APICALLBOOM_PARAM,
"spForgotPass_Request", {
{ "iLogin", _emailOrMobile },
{ "iBy", Type },
});

return true; //(Type == "E" ? "email" : "mobile");
}

bool IMPL_REST_GET_OR_POST(Account, changePassByUUID, (
APICALLBOOM_TYPE_JWT_ANONYMOUSE_IMPL &APICALLBOOM_PARAM,
QString _emailOrMobile,
Expand All @@ -665,6 +665,12 @@ bool IMPL_REST_GET_OR_POST(Account, changePassByUUID, (

QString Type = PhoneHelper::ValidateAndNormalizeEmailOrPhoneNumber(_emailOrMobile);

if (_uuid.isEmpty())
throw exHTTPBadRequest("UUID is empty");

if (_newPass.isEmpty())
throw exHTTPBadRequest("New password is empty");

this->callSP(APICALLBOOM_PARAM,
"spPassword_ChangeByCode", {
{ "iBy", Type },
Expand Down
18 changes: 9 additions & 9 deletions Modules/Account/moduleSrc/Account.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,6 @@ private slots:
"Logout logged in user"
)

bool REST_GET_OR_POST(
createForgotPasswordLink,
(
APICALLBOOM_TYPE_JWT_ANONYMOUSE_DECL &APICALLBOOM_PARAM,
QString _emailOrMobile
),
"Create a forgot password request returning a UUID for the request"
)

bool REST_GET_OR_POST(
changePass,
(
Expand All @@ -255,6 +246,15 @@ private slots:
"Do not set oldPass to set a new password when the current password is empty."
)

bool REST_GET_OR_POST(
createForgotPasswordLink,
(
APICALLBOOM_TYPE_JWT_ANONYMOUSE_DECL &APICALLBOOM_PARAM,
QString _emailOrMobile
),
"Create a forgot password request returning a UUID for the request"
)

bool REST_GET_OR_POST(
changePassByUUID,
(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Migration File: m20221017_101642_Common_fix_update_apr_in_trigger.sql */
/* CAUTION: don't forget to use {{dbprefix}} for schemas */

USE `{{dbprefix}}{{Schema}}`;

DROP TRIGGER IF EXISTS `tblAlerts_after_update`;
DELIMITER //
CREATE TRIGGER `tblAlerts_after_update` AFTER UPDATE ON `tblAlerts` FOR EACH ROW BEGIN
IF (NEW.alrStatus = 'S' AND NEW.alrSentDate IS NOT NULL AND OLD.alrSentDate IS NULL) THEN
-- 1: update tblApprovalRequest
UPDATE {{dbprefix}}AAA.tblApprovalRequest
SET aprStatus = 'S'
, aprSentDate = NEW.alrSentDate
WHERE aprStatus != 'S'
AND aprSentDate IS NULL
AND IFNULL(apr_usrID, 0) = IFNULL(NEW.alr_usrID, 0)
AND aprRequestedFor = IF(NEW.alr_altCode = 'approveEmail', 'E', 'M')
AND aprApprovalKey = NEW.alrReplacedContactInfo
AND aprApprovalCode = JSON_EXTRACT(NEW.alrReplacements, IF(NEW.alr_altCode = 'approveEmail', '$.UUID', '$.ApprovalCode'))
;

-- 2: update tblForgotPassRequest
UPDATE {{dbprefix}}AAA.tblForgotPassRequest
SET fprStatus = 'S'
-- , fprSentDate = NEW.alrSentDate
WHERE fprStatus != 'S'
-- AND fprSentDate IS NULL
AND fpr_usrID = NEW.alr_usrID
AND fprRequestedVia = IF(NEW.alr_altCode = 'passResetByEmail', 'E', 'M')
AND fprCode = JSON_EXTRACT(NEW.alrReplacements, IF(NEW.alr_altCode = 'passResetByEmail', '$.UUID', '$.ApprovalCode'))
;

END IF;
END//
DELIMITER ;