Skip to content

Commit

Permalink
Fourth attempt to implement SMS 2FA for #51
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum committed May 30, 2024
1 parent 10071cd commit 809c656
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions source/server/appleaccount.d
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,22 @@ package class AppleAccount {

"User-Agent": applicationInformation.applicationName
]);
request.addHeaders(applicationInformation.headers);

// sends code to the trusted devices
bool delegate() sendCode = () {
auto res = request.get(urls["trustedDeviceSecondaryAuth"]);
return res.code == 200;
};
bool delegate() sendCode;
if (urlBagKey == "trustedDeviceSecondaryAuth") {
sendCode = () {
auto res = request.get(urls["trustedDeviceSecondaryAuth"]);
return res.code == 200;
};
} else {
sendCode = () {
// urls["trustedDeviceSecondaryAuth"] to select the right phone number.
auto res = request.put("https://gsa.apple.com/auth/verify/phone/", `{"phoneNumber": {"id": 1}, "mode": "sms"}`);
return res.code == 200;
};
}

// submits the given code to Apple servers
AppleSecondaryActionResponse response = AppleSecondaryActionResponse(AppleLoginError(AppleLoginErrorCode.no2FAAttempt, "2FA has not been completed."));
Expand Down Expand Up @@ -176,7 +186,6 @@ package class AppleAccount {
};
}


tfaHandler(sendCode, submitCode);
return response;
});
Expand Down

0 comments on commit 809c656

Please sign in to comment.