diff --git a/config.json b/config.json index 24792b8..9f4458f 100644 --- a/config.json +++ b/config.json @@ -4,13 +4,6 @@ "address": "0.0.0.0", "port": 80, "https": false - }, - { - "address": "0.0.0.0", - "port": 443, - "https": true, - "cert": "", - "key": "" } ] } \ No newline at end of file diff --git a/include/bank.hpp b/include/bank.hpp index fb136ee..9425132 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -108,10 +108,19 @@ public: if (state) { + //if user lacks a log, one is created, this is to reduce usage Transaction temp(a_name, b_name, amount, false); + if (!logs.contains(a_name)) + { + logs.try_emplace(a_name); + } logs.modify_if(a_name, [&temp](Log &l) { l.AddTrans(temp); }); + if (!logs.contains(b_name)) + { + logs.try_emplace(b_name); + } temp.recieving = true; logs.modify_if(b_name, [&temp](Log &l) { l.AddTrans(temp); @@ -194,7 +203,7 @@ public: }); return res; } - return -1; + return users.contains(name); // so that if the user has no logs, but does exist } void Save() @@ -239,7 +248,6 @@ public: user_save.close(); for (const auto &u : temp.getMemberNames()) { - logs.try_emplace(u); users.try_emplace(u, temp[u]["balance"].asUInt(), std::move(temp[u]["password"].asUInt64())); } } diff --git a/include/bank_f.hpp b/include/bank_f.hpp index d1d1885..3d3ade8 100644 --- a/include/bank_f.hpp +++ b/include/bank_f.hpp @@ -37,7 +37,7 @@ public: { auto resp = HttpResponse::newHttpResponse(); auto handlerInfo = app().getHandlersInfo(); - resp->setBody("
attempt - admin password
Closes and Saves the server.
name - name of the user being added
init_pass - initial password for the user being added
Adds a user to the bank
name - name of the user being added
attempt - admin password required to add user with balance
init_bal - initial balance for user being added
init_pass - initial password for user being added
Adds a user with initial balance
a_name - sender's name
b_name - reciever's name
amount - amount being sent
attempt - password of sender
Sends money from one user to another
name - name of user's password being changes
attempt - password of user being changed
new_pass - new password to replace the current user's password
Changes password of a user, returns -1 if user doesnt exist
name - the name of the user being set
attempt - the admin password required
amount - the new balance of the user
Sets the balance of a user
the page you're looking at right now!
name - name of user being verified
attempt - password being verified
returns 0 or 1 based on if [attempt] is equal to the password of the user [name], or -1 if user does not exist. The intended usage for this function is for connected services
returns a 0 or 1 based on if the bank contains the user
returns the balance of a given user's name, if -1 that means the user does not exist
attempt - admin password
Verifies if password entered is admin password
attempt - user password
returns a list of last 100 transactions, -1 if user not found
name - name of user being deleted
attempt - password of user being deleted
Deletes a user with the password of the user as verification
name - name of user being deleted
attempt - admin password
"); + resp->setBody("Deletes a user with admin password as verification
attempt - admin password
Closes and Saves the server.
name - name of the user being added
init_pass - initial password for the user being added
Adds a user to the bank
name - name of the user being added
attempt - admin password required to add user with balance
init_bal - initial balance for user being added
init_pass - initial password for user being added
Adds a user with initial balance
a_name - sender's name
b_name - reciever's name
amount - amount being sent
attempt - password of sender
Sends money from one user to another
name - name of user's password being changes
attempt - password of user being changed
new_pass - new password to replace the current user's password
Changes password of a user, returns -1 if user doesnt exist
name - the name of the user being set
attempt - the admin password required
amount - the new balance of the user
Sets the balance of a user
the page you're looking at right now!
name - name of user being verified
attempt - password being verified
returns 0 or 1 based on if [attempt] is equal to the password of the user [name], or -1 if user does not exist. The intended usage for this function is for connected services
returns a 0 or 1 based on if the bank contains the user
returns the balance of a given user's name, if -1 that means the user does not exist
attempt - admin password
Verifies if password entered is admin password
attempt - user password
returns a list of last 100 transactions, 0 if user not found, returns 1 if user exists but has no logs
name - name of user being deleted
attempt - password of user being deleted
Deletes a user with the password of the user as verification
name - name of user being deleted
attempt - admin password
"); resp->setExpiredTime(0); callback(resp); }Deletes a user with admin password as verification