Password registration/reset confirmation at entry
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@ -346,15 +346,17 @@ int main(int argc, char *argv[]) {
|
|||||||
string postRequestBody = postRequest.body;
|
string postRequestBody = postRequest.body;
|
||||||
Utilities::decodeString(postRequestBody);
|
Utilities::decodeString(postRequestBody);
|
||||||
vector<string> splitPostRequestBody = Utilities::splitStringIntoVector(postRequestBody, '&');
|
vector<string> splitPostRequestBody = Utilities::splitStringIntoVector(postRequestBody, '&');
|
||||||
string password;
|
string password, passwordConfirmation;
|
||||||
for (const string& item : splitPostRequestBody) {
|
for (const string& item : splitPostRequestBody) {
|
||||||
vector<string> splitItem = Utilities::splitStringIntoVector(item, '=');
|
vector<string> splitItem = Utilities::splitStringIntoVector(item, '=');
|
||||||
if (splitItem.at(0) == "freelancerpassword")
|
if (splitItem.at(0) == "freelancerpassword")
|
||||||
password = splitItem.at(1);
|
password = splitItem.at(1);
|
||||||
|
if (splitItem.at(0) == "freelancerpasswordconfirmation")
|
||||||
|
passwordConfirmation = splitItem.at(1);
|
||||||
}
|
}
|
||||||
pqxx::connection databaseConnection(configuration.databaseConnectionString);
|
pqxx::connection databaseConnection(configuration.databaseConnectionString);
|
||||||
pqxx::result freelancerEmail = Database::executePreparedStatement_SELECT_FREELANCER_EMAIL_FROM_PASSWORD_RESET_KEY(databaseConnection, passwordResetKey);
|
pqxx::result freelancerEmail = Database::executePreparedStatement_SELECT_FREELANCER_EMAIL_FROM_PASSWORD_RESET_KEY(databaseConnection, passwordResetKey);
|
||||||
if (!freelancerEmail.empty() && !password.empty()) {
|
if (!freelancerEmail.empty() && !password.empty() && !(password.compare(passwordConfirmation) == 0)) {
|
||||||
string email = freelancerEmail.at(0).at(0).c_str();
|
string email = freelancerEmail.at(0).at(0).c_str();
|
||||||
pqxx::result keyExpiration = Database::executePreparedStatement_SELECT_CHECK_FREELANCER_RESET_KEY_EXPIRED(databaseConnection, email);
|
pqxx::result keyExpiration = Database::executePreparedStatement_SELECT_CHECK_FREELANCER_RESET_KEY_EXPIRED(databaseConnection, email);
|
||||||
if (stoi(keyExpiration.at(0).at(0).c_str()) == 0) {
|
if (stoi(keyExpiration.at(0).at(0).c_str()) == 0) {
|
||||||
@ -385,6 +387,8 @@ int main(int argc, char *argv[]) {
|
|||||||
ctx["PASSWORD_EMPTY"] = true;
|
ctx["PASSWORD_EMPTY"] = true;
|
||||||
if (freelancerEmail.empty())
|
if (freelancerEmail.empty())
|
||||||
ctx["PASSWORD_RESET_DOES_NOT_EXIST"] = true;
|
ctx["PASSWORD_RESET_DOES_NOT_EXIST"] = true;
|
||||||
|
if (!(password.compare(passwordConfirmation) == 0))
|
||||||
|
ctx["PASSWORD_RESET_PASS_CONFIRMATION"] = true;
|
||||||
}
|
}
|
||||||
auto page = crow::mustache::load("passwordReset_Fulfillment.html");
|
auto page = crow::mustache::load("passwordReset_Fulfillment.html");
|
||||||
return page.render(ctx);
|
return page.render(ctx);
|
||||||
@ -485,7 +489,7 @@ int main(int argc, char *argv[]) {
|
|||||||
Utilities::decodeString(postRequestBody);
|
Utilities::decodeString(postRequestBody);
|
||||||
vector<string> splitPostRequestBody = Utilities::splitStringIntoVector(postRequestBody, '&');
|
vector<string> splitPostRequestBody = Utilities::splitStringIntoVector(postRequestBody, '&');
|
||||||
|
|
||||||
string name, email, password;
|
string name, email, password, passwordConfirmation;
|
||||||
|
|
||||||
bool requestFillCompletion = false;
|
bool requestFillCompletion = false;
|
||||||
for (const string& item : splitPostRequestBody) {
|
for (const string& item : splitPostRequestBody) {
|
||||||
@ -496,10 +500,12 @@ int main(int argc, char *argv[]) {
|
|||||||
email = splitItem.at(1);
|
email = splitItem.at(1);
|
||||||
if (splitItem.at(0) == "freelancerpassword")
|
if (splitItem.at(0) == "freelancerpassword")
|
||||||
password = splitItem.at(1);
|
password = splitItem.at(1);
|
||||||
|
if (splitItem.at(0) == "freelancerpasswordconfirmation")
|
||||||
|
passwordConfirmation = splitItem.at(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if signup data is complete
|
//check if signup data is complete
|
||||||
if (!email.empty() && !name.empty() && !password.empty())
|
if (!email.empty() && !name.empty() && !password.empty() && !(password.compare(passwordConfirmation) == 0))
|
||||||
requestFillCompletion = true;
|
requestFillCompletion = true;
|
||||||
|
|
||||||
if (requestFillCompletion) {
|
if (requestFillCompletion) {
|
||||||
@ -536,6 +542,8 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ctx["REGISTRATION_ERROR"] = true;
|
ctx["REGISTRATION_ERROR"] = true;
|
||||||
|
if (!(password.compare(passwordConfirmation) == 0))
|
||||||
|
ctx["REGISTRATION_ERROR_PASS_CONFIRMATION"] = true;
|
||||||
ctx["REGISTRATION_ERROR_EMAIL_NAME_PASS_NOT_FILLED"] = true;
|
ctx["REGISTRATION_ERROR_EMAIL_NAME_PASS_NOT_FILLED"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<label for="freelancername">Name:</label> <input type="text" id="freelancername" name="freelancername" value=""><br>
|
<label for="freelancername">Name:</label> <input type="text" id="freelancername" name="freelancername" value=""><br>
|
||||||
<label for="freelanceremail">E-Mail:</label> <input type="email" id="freelanceremail" name="freelanceremail" value=""><br>
|
<label for="freelanceremail">E-Mail:</label> <input type="email" id="freelanceremail" name="freelanceremail" value=""><br>
|
||||||
<label for="freelancerpassword">Password: </label> <input type="password" id="freelancerpassword" name="freelancerpassword" value=""><br>
|
<label for="freelancerpassword">Password: </label> <input type="password" id="freelancerpassword" name="freelancerpassword" value=""><br>
|
||||||
|
<label for="freelancerpasswordconfirmation">Confirm Password: </label> <input type="password" id="freelancerpasswordconfirmation" name="freelancerpasswordconfirmation" value=""><br>
|
||||||
<button type="submit" class="button">Sign Up</button>
|
<button type="submit" class="button">Sign Up</button>
|
||||||
</form>
|
</form>
|
||||||
<br>
|
<br>
|
||||||
|
@ -26,9 +26,14 @@
|
|||||||
{{/REGISTRATION_ERROR_EMAIL_ALREADY_IN_USE}}
|
{{/REGISTRATION_ERROR_EMAIL_ALREADY_IN_USE}}
|
||||||
{{#REGISTRATION_ERROR_EMAIL_NAME_PASS_NOT_FILLED}}
|
{{#REGISTRATION_ERROR_EMAIL_NAME_PASS_NOT_FILLED}}
|
||||||
<div>
|
<div>
|
||||||
The registration form has not been filled out completely
|
The registration form has not been filled out completely.
|
||||||
</div>
|
</div>
|
||||||
{{/REGISTRATION_ERROR_EMAIL_NAME_PASS_NOT_FILLED}}
|
{{/REGISTRATION_ERROR_EMAIL_NAME_PASS_NOT_FILLED}}
|
||||||
|
{{#REGISTRATION_ERROR_PASS_CONFIRMATION}}
|
||||||
|
<div>
|
||||||
|
The Password does not equal the confirmation.
|
||||||
|
</div>
|
||||||
|
{{/REGISTRATION_ERROR_PASS_CONFIRMATION}}
|
||||||
{{#REGISTRATION_ERROR}}
|
{{#REGISTRATION_ERROR}}
|
||||||
<form action="/freelancer/signup" method="get">
|
<form action="/freelancer/signup" method="get">
|
||||||
<button type="submit" class="button">Registration Error: Return to signup</button>
|
<button type="submit" class="button">Registration Error: Return to signup</button>
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<form action="/passwordreset/{{passwordresetkey}}/fulfilment" method="post">
|
<form action="/passwordreset/{{passwordresetkey}}/fulfilment" method="post">
|
||||||
<label for="freelancerpassword">Password: </label> <input type="password" id="freelancerpassword" name="freelancerpassword" value=""><br>
|
<label for="freelancerpassword">Password: </label> <input type="password" id="freelancerpassword" name="freelancerpassword" value=""><br>
|
||||||
|
<label for="freelancerpasswordconfirmation">Confirm Password: </label> <input type="password" id="freelancerpasswordconfirmation" name="freelancerpasswordconfirmation" value=""><br>
|
||||||
<button type="submit" class="button">Reset Password</button>
|
<button type="submit" class="button">Reset Password</button>
|
||||||
</form>
|
</form>
|
||||||
<br>
|
<br>
|
||||||
|
@ -23,6 +23,11 @@
|
|||||||
No new password has been entered.
|
No new password has been entered.
|
||||||
</div>
|
</div>
|
||||||
{{/PASSWORD_EMPTY}}
|
{{/PASSWORD_EMPTY}}
|
||||||
|
{{#PASSWORD_RESET_PASS_CONFIRMATION}}
|
||||||
|
<div>
|
||||||
|
The Password does not equal the confirmation.
|
||||||
|
</div>
|
||||||
|
{{/PASSWORD_RESET_PASS_CONFIRMATION}}
|
||||||
{{#PASSWORD_RESET_EXPIRED}}
|
{{#PASSWORD_RESET_EXPIRED}}
|
||||||
<div>
|
<div>
|
||||||
The password request has expired.
|
The password request has expired.
|
||||||
|
Reference in New Issue
Block a user