summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interchange/member.hxx3
-rw-r--r--member.cxx51
2 files changed, 31 insertions, 23 deletions
diff --git a/interchange/member.hxx b/interchange/member.hxx
index 560cea4..5137071 100644
--- a/interchange/member.hxx
+++ b/interchange/member.hxx
@@ -81,7 +81,8 @@ namespace QInterchange {
void newAccount(QString const& username,
QString const& password,
QString const& confirm,
- QString const& failPage = nullptr);
+ QString const& nextPage = "",
+ QString const& failPage = "");
void logIn(QString const& userName,
QString const& passWord,
QString const& nextPage = "",
diff --git a/member.cxx b/member.cxx
index a346d74..420f76c 100644
--- a/member.cxx
+++ b/member.cxx
@@ -98,29 +98,36 @@ namespace QInterchange {
void Member::newAccount(QString const& username,
QString const& password, QString const& verify,
- QString const& failPage)
+ QString const& nextPage, QString const& failPage)
{
- auto unData = username.toLatin1().constData();
- unCopy = (char*)malloc(strlen(unData) + 1);
- strcpy(unCopy, unData);
- auto pwData = password.toLatin1().constData();
- pwCopy = (char*)malloc(strlen(pwData) + 1);
- strcpy(pwCopy, pwData);
- auto vData = verify.toLatin1().constData();
- vCopy = (char*)malloc(strlen(vData) + 1);
- strcpy(vCopy, vData);
- auto fpData = failPage.toLatin1().constData();
- fpCopy = (char*)malloc(strlen(fpData) + 1);
- strcpy(fpCopy, fpData);
- interchange_member_newaccount(unCopy, pwCopy, vCopy, fpCopy,
- [](interchange_response* response) {
- free(unCopy);
- free(pwCopy);
- free(vCopy);
- free(fpCopy);
- member->emitCreation(QString{response->data});
- interchange_free_response(response);
- }, nullptr);
+ unCopy = (char*)malloc(username.size() + 1);
+ strcpy(unCopy, username.toLatin1().constData());
+ pwCopy = (char*)malloc(password.size() + 1);
+ strcpy(pwCopy, password.toLatin1().constData());
+ vCopy = (char*)malloc(verify.size() + 1);
+ strcpy(vCopy, verify.toLatin1().constData());
+ if (nextPage.isEmpty())
+ npCopy = nullptr;
+ else {
+ npCopy = (char*)malloc(nextPage.size() + 1);
+ strcpy(npCopy, nextPage.toLatin1().constData());
+ }
+ if (failPage.isEmpty())
+ fpCopy = nullptr;
+ else {
+ fpCopy = (char*)malloc(failPage.size() + 1);
+ strcpy(fpCopy, failPage.toLatin1().constData());
+ }
+ interchange_member_newaccount(unCopy, pwCopy, vCopy, npCopy,
+ fpCopy, [](interchange_response* response) {
+ free(unCopy);
+ free(pwCopy);
+ free(vCopy);
+ if (npCopy) free(npCopy);
+ if (fpCopy) free(fpCopy);
+ member->emitCreation(QString{response->data});
+ interchange_free_response(response);
+ }, nullptr);
}
void Member::logIn(QString const& username, QString const& password,