mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
UserResolver
- on login have a specific message for deleted users - when trying to register also check for deleted users and prevent registration
This commit is contained in:
parent
8eaed23af4
commit
90bdca04a6
@ -250,9 +250,12 @@ export class UserResolver {
|
|||||||
@Ctx() context: any,
|
@Ctx() context: any,
|
||||||
): Promise<User> {
|
): Promise<User> {
|
||||||
email = email.trim().toLowerCase()
|
email = email.trim().toLowerCase()
|
||||||
const dbUser = await DbUser.findOneOrFail({ email }).catch(() => {
|
const dbUser = await DbUser.findOneOrFail({ email }, { withDeleted: true }).catch(() => {
|
||||||
throw new Error('No user with this credentials')
|
throw new Error('No user with this credentials')
|
||||||
})
|
})
|
||||||
|
if (dbUser.deletedAt) {
|
||||||
|
throw new Error('This user was permanently disabled. Contact support for questions.')
|
||||||
|
}
|
||||||
if (!dbUser.emailChecked) {
|
if (!dbUser.emailChecked) {
|
||||||
throw new Error('User email not validated')
|
throw new Error('User email not validated')
|
||||||
}
|
}
|
||||||
@ -335,9 +338,9 @@ export class UserResolver {
|
|||||||
|
|
||||||
// Validate email unique
|
// Validate email unique
|
||||||
// TODO: i can register an email in upper/lower case twice
|
// TODO: i can register an email in upper/lower case twice
|
||||||
const userRepository = getCustomRepository(UserRepository)
|
// TODO we cannot use repository.count(), since it does not allow to specify if you want to include the soft deletes
|
||||||
const usersFound = await userRepository.count({ email })
|
const userFound = await DbUser.findOne({ email }, { withDeleted: true })
|
||||||
if (usersFound !== 0) {
|
if (userFound) {
|
||||||
// TODO: this is unsecure, but the current implementation of the login server. This way it can be queried if the user with given EMail is existent.
|
// TODO: this is unsecure, but the current implementation of the login server. This way it can be queried if the user with given EMail is existent.
|
||||||
throw new Error(`User already exists.`)
|
throw new Error(`User already exists.`)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user