@@ -27,7 +27,7 @@ export class CreateAuth {
|
||||
if (!this.password) {
|
||||
throw new PasswordNeededError();
|
||||
}
|
||||
const found_user = await getConnectionManager().get().getRepository(User).findOne({ relations: ['groups', 'permissions'], where: [{ username: this.username }, { email: this.email }] });
|
||||
const found_user = await getConnectionManager().get().getRepository(User).findOne({ relations: ['groups', 'permissions', 'groups.permissions'], where: [{ username: this.username }, { email: this.email }] });
|
||||
if (!found_user) {
|
||||
throw new UserNotFoundError();
|
||||
}
|
||||
|
||||
@@ -101,22 +101,11 @@ export class CreateUser {
|
||||
if (!Array.isArray(this.group)) {
|
||||
this.group = [this.group]
|
||||
}
|
||||
const groupIDs: number[] = this.group
|
||||
let errors = 0
|
||||
const validateusergroups = async () => {
|
||||
for (const g of groupIDs) {
|
||||
const found = await getConnectionManager().get().getRepository(UserGroup).find({ id: g });
|
||||
if (found.length === 0) {
|
||||
errors++
|
||||
} else {
|
||||
groups.push(found[0]);
|
||||
}
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
await validateusergroups()
|
||||
if (errors !== 0) {
|
||||
throw new UserGroupNotFoundError();
|
||||
for (let group of this.group) {
|
||||
let found = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: group });
|
||||
if (!found) { throw new UserGroupNotFoundError(); }
|
||||
groups.push(found);
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user