Skip to content

Commit

Permalink
FIX : deleted user management
Browse files Browse the repository at this point in the history
  • Loading branch information
juliecoust committed Jul 1, 2024
1 parent 8a7fbee commit 7c2f967
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 156 deletions.
3 changes: 2 additions & 1 deletion src/domain/use-cases/user/create-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export class CreateUser implements CreateUserUseCase {
// Check if a user with the given email already exists
if (preexistentUser) {
// User should not be deleted
if (preexistentUser.deleted !== undefined) throw new Error("User is deleted");
console.log(preexistentUser)
if (preexistentUser.deleted) throw new Error("User is deleted");

// If the user exists but hasn't validated their email
if (!preexistentUser.valid_email) {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/use-cases/user/update-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class UpdateUser implements UpdateUserUseCase {

const user = await this.userRepository.getUser({ user_id: user_to_update.user_id })
if (!user) throw new Error("Cannot find user to update");
if (user.deleted !== undefined) throw new Error("User to update is deleted");
if (user.deleted) throw new Error("User to update is deleted");

// Update admin can update anyone
if (await this.userRepository.isAdmin(current_user.user_id)) {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/use-cases/user/valid-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ValidUser implements ValidUserUseCase {
if (!user_to_update) throw new Error("Cannot find user with confirmation code");

// User should not be deleted
if (user_to_update.deleted !== undefined) throw new Error("User is deleted");
if (user_to_update.deleted) throw new Error("User is deleted");

// Update validation status of the found user
const nb_updated_user = await this.userRepository.validUser({ user_id: user_to_update.user_id })
Expand Down
153 changes: 0 additions & 153 deletions user-validation.ts

This file was deleted.

0 comments on commit 7c2f967

Please sign in to comment.