diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-03-13 17:58:47 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-03-13 17:58:47 +0800 |
commit | 321b3eeb6d7fcb5568f6a469127ff830ab77556d (patch) | |
tree | 0fed55a5a8edd16d7ada41bb729b08b95ecceca5 /member.cxx | |
parent | 000716f554aad82d774f7ef1c7b09e82e3342546 (diff) |
Interface for setting new account next page
Diffstat (limited to 'member.cxx')
-rw-r--r-- | member.cxx | 51 |
1 files changed, 29 insertions, 22 deletions
@@ -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, |