Skip to content

Commit

Permalink
fix: verified account being freed - fix #42 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
pagoru authored Aug 19, 2024
1 parent 198a371 commit 2c046b4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/server/src/modules/api/v2/account/login.http
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ POST http://localhost:2024/api/v2/account/login
Content-Type: application/json

{
"ticketId": "53f18071-0327-4c7d-a74f-5d19611295cc",
"ticketId": "aa3b3fc4-3207-44dc-9f87-f0da77665240",

"email": "[email protected]",
"password": "123456Abc*",
Expand Down
1 change: 1 addition & 0 deletions app/server/src/modules/api/v2/account/login.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const loginRequest: RequestType = {
email,
]);

console.log(!accountByEmail);
if (!accountByEmail)
return Response.json(
{ status: 403 },
Expand Down
1 change: 1 addition & 0 deletions app/server/src/modules/api/v2/account/register.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const registerRequest: RequestType = {
`<a href="${verifyUrl}">${verifyUrl}<p/>`,
);

// Every key related to the account is temporary until the account is verified or freed if not
await System.db.set(
["accounts", accountId],
{
Expand Down
7 changes: 7 additions & 0 deletions app/server/src/modules/api/v2/account/verify.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { RequestType } from "shared/types/main.ts";
import { RequestMethod } from "shared/enums/main.ts";
import { System } from "system/main.ts";
import * as bcrypt from "bcrypt";
import { ACCOUNT_EXPIRE_TIME } from "shared/consts/account.consts.ts";

export const verifyRequest: RequestType = {
method: RequestMethod.GET,
Expand Down Expand Up @@ -57,7 +58,13 @@ export const verifyRequest: RequestType = {
delete account.verifyTokensHash;

await System.db.delete(["accountsByVerifyId", id]);

await System.db.set(["accounts", account.accountId], account);
await System.db.set(["accountsByEmail", account.email], account.accountId);
await System.db.set(
["accountsByUsername", account.username.toLowerCase()],
account.accountId,
);

return Response.json(
{
Expand Down

0 comments on commit 2c046b4

Please sign in to comment.