Skip to content

Commit

Permalink
fix(api): update sign up flow for sws pocket
Browse files Browse the repository at this point in the history
  • Loading branch information
sws2apps-admin authored Dec 5, 2022
1 parent 3f9e6ad commit 81b2d4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
10 changes: 6 additions & 4 deletions src/classes/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ export class User {

this.pocket_oCode = secureCode;

await Users.loadAll();

return code;
} catch (error) {
throw new Error(error.message);
Expand Down Expand Up @@ -282,8 +284,8 @@ export class User {
assignCongregation = async (congInfo) => {
try {
await db.collection("users").doc(this.id).set(congInfo, { merge: true });
await Users.loadAll()

await Users.loadAll();
await Congregations.loadAll();
} catch (err) {
throw new Error(err.message);
Expand Down Expand Up @@ -368,9 +370,9 @@ export class User {
...filteredDevices,
];

await db.collection("users").doc(this.id).update({ "congregation.devices": updatedDevices });
await db.collection("users").doc(this.id).update({ "congregation.devices": updatedDevices, "congregation.oCode": FieldValue.delete() });

await Users.loadAll()
await Users.loadAll();
await Congregations.loadAll();
};

Expand Down
17 changes: 7 additions & 10 deletions src/classes/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,21 @@ class clsUsers {
};

findUserByOTPCode = (code) => {
try {
let user;
for (let i = 0; i < this.list.length; i++) {
const item = this.list[i];
const otpCode = item.pocket_oCode;

let user;
for (let i = 0; i < this.list.length; i++) {
const item = this.list[i];
const otpCode = item.pocket_oCode;
if (otpCode !== "") {
const pocket_oCode = decryptData(otpCode);

if (code === pocket_oCode) {
user = item;
break;
}
}

return user;
} catch (error) {
throw new Error(error.message);
}

return user;
};

findPocketUser = (pocketId) => {
Expand Down

0 comments on commit 81b2d4a

Please sign in to comment.