Skip to content

Commit

Permalink
chore(user): remove active and lastRequest fields
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAndersen committed Dec 26, 2024
1 parent de69375 commit c7a2c5c
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 43 deletions.
2 changes: 0 additions & 2 deletions backend/src/auth/local/local-login.validator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ describe("LocalLoginValidator", () => {
blid: "",
username: username,
valid: true,
active: true,
lastRequest: "",
} as User);
});

Expand Down
12 changes: 0 additions & 12 deletions backend/src/auth/user/user.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const testUser = {
blid: "",
username: "[email protected]",
valid: false,
active: true,
} as User;

describe("UserHandler", () => {
Expand Down Expand Up @@ -331,15 +330,4 @@ describe("UserHandler", () => {
});
});
});

describe("#valid", () => {
it("should reject if user.active is false", () => {
testUser.active = false;

return expect(userHandler.valid(testUsername)).to.be.rejectedWith(
BlError,
/user.active is false/,
);
});
});
});
6 changes: 1 addition & 5 deletions backend/src/auth/user/user.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,7 @@ export class UserHandler {
public valid(username: string): Promise<void> {
return new Promise((resolve, reject) => {
this.getByUsername(username)
.then((user: User) => {
if (!user.active) {
return reject(new BlError("user.active is false").code(913));
}

.then(() => {
resolve();
})
.catch((getUserError: BlError) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ describe("PendingPasswordResetPostHook", () => {
id: "u#xyz",
permission: "customer",
},
active: true,
} as User;
});

Expand Down Expand Up @@ -104,16 +103,6 @@ describe("PendingPasswordResetPostHook", () => {
);
});

describe("when user is found in storage", () => {
it("should reject if user.active is false", async () => {
testUser.active = false;

await expect(
pendingPasswordResetPostHook.before(testPasswordResetRequest),
).to.be.rejectedWith(BlError, /user.active is false/);
});
});

beforeEach(() => {
testPendingPasswordReset = {
id: "passwordReset1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ export class PendingPasswordResetPostHook extends Hook {
.add(getUserError);
});

if (!user.active) {
throw new BlError("user.active is false").code(10_703);
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const id = this.seCrypto.random();
Expand Down
7 changes: 0 additions & 7 deletions backend/src/collections/user/user.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,4 @@ export const UserSchema = new Schema<ToSchema<User>>({
type: Boolean,
},
movedToPrimary: Schema.Types.ObjectId,
active: {
type: Boolean,
default: true,
},
lastRequest: {
type: String,
},
});
2 changes: 0 additions & 2 deletions backend/src/collections/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export interface User {
id: string;
permission: UserPermission;
};
active?: boolean;
primary?: boolean; // if user had multiple user details, this flag sets this to the primary
movedToPrimary?: string; // if user had multiple user details, this is set to link to the primary user
lastRequest?: string;
}

0 comments on commit c7a2c5c

Please sign in to comment.