Merge branch 'dev' into feature/17-automated_tests

This commit is contained in:
Nicolai Ort 2020-12-09 19:02:29 +01:00
commit ff96ba23d7
9 changed files with 11 additions and 13 deletions

View File

@ -26,7 +26,7 @@ export class AuthController {
try { try {
auth = await createAuth.toAuth(); auth = await createAuth.toAuth();
} catch (error) { } catch (error) {
return error; throw error;
} }
return auth return auth
} }

View File

@ -54,7 +54,7 @@ export class RunnerController {
try { try {
runner = await createRunner.toRunner(); runner = await createRunner.toRunner();
} catch (error) { } catch (error) {
return error; throw error;
} }
runner = await this.runnerRepository.save(runner) runner = await this.runnerRepository.save(runner)

View File

@ -54,7 +54,7 @@ export class RunnerOrganisationController {
try { try {
runnerOrganisation = await createRunnerOrganisation.toRunnerOrganisation(); runnerOrganisation = await createRunnerOrganisation.toRunnerOrganisation();
} catch (error) { } catch (error) {
return error; throw error;
} }
runnerOrganisation = await this.runnerOrganisationRepository.save(runnerOrganisation); runnerOrganisation = await this.runnerOrganisationRepository.save(runnerOrganisation);

View File

@ -53,7 +53,7 @@ export class RunnerTeamController {
try { try {
runnerTeam = await createRunnerTeam.toRunnerTeam(); runnerTeam = await createRunnerTeam.toRunnerTeam();
} catch (error) { } catch (error) {
return error; throw error;
} }
runnerTeam = await this.runnerTeamRepository.save(runnerTeam); runnerTeam = await this.runnerTeamRepository.save(runnerTeam);

View File

@ -44,7 +44,7 @@ export class UserController {
try { try {
user = await createUser.toUser(); user = await createUser.toUser();
} catch (error) { } catch (error) {
return error; throw error;
} }
return this.userRepository.save(user); return this.userRepository.save(user);

View File

@ -43,7 +43,7 @@ export class UserGroupController {
try { try {
userGroup = await createUserGroup.toUserGroup(); userGroup = await createUserGroup.toUserGroup();
} catch (error) { } catch (error) {
return error; throw error;
} }
return this.userGroupsRepository.save(userGroup); return this.userGroupsRepository.save(userGroup);

View File

@ -28,13 +28,14 @@ export class CreateAuth {
if (!this.password) { if (!this.password) {
throw new PasswordNeededError() throw new PasswordNeededError()
} }
const found_users = await getConnectionManager().get().getRepository(User).find({ where: [{ username: this.username }, { email: this.email }] }); const found_users = await getConnectionManager().get().getRepository(User).find({ relations: ['groups', 'permissions'], where: [{ username: this.username }, { email: this.email }] });
if (found_users.length === 0) { if (found_users.length === 0) {
throw new UserNotFoundError() throw new UserNotFoundError()
} else { } else {
const found_user = found_users[0] const found_user = found_users[0]
if (await argon2.verify(found_user.password, this.password + found_user.uuid)) { if (await argon2.verify(found_user.password, this.password + found_user.uuid)) {
const timestamp_accesstoken_expiry = Math.floor(Date.now() / 1000) + 5 * 60 const timestamp_accesstoken_expiry = Math.floor(Date.now() / 1000) + 5 * 60
found_user.permissions = found_user.permissions || []
delete found_user.password; delete found_user.password;
newAuth.access_token = jsonwebtoken.sign({ newAuth.access_token = jsonwebtoken.sign({
userdetails: found_user, userdetails: found_user,

View File

@ -35,11 +35,7 @@ export class CreateRunnerTeam extends CreateRunnerGroup {
let newRunnerTeam: RunnerTeam = new RunnerTeam(); let newRunnerTeam: RunnerTeam = new RunnerTeam();
newRunnerTeam.name = this.name; newRunnerTeam.name = this.name;
try { newRunnerTeam.parentGroup = await this.getParent();
newRunnerTeam.parentGroup = await this.getParent();
} catch (error) {
throw error;
}
newRunnerTeam.contact = await this.getContact() newRunnerTeam.contact = await this.getContact()

View File

@ -21,13 +21,14 @@ export class RefreshAuth {
} catch (error) { } catch (error) {
throw new IllegalJWTError() throw new IllegalJWTError()
} }
const found_user = await getConnectionManager().get().getRepository(User).findOne({ id: decoded["userid"] }); const found_user = await getConnectionManager().get().getRepository(User).findOne({ id: decoded["userid"] }, { relations: ['groups', 'permissions'] });
if (!found_user) { if (!found_user) {
throw new UserNotFoundError() throw new UserNotFoundError()
} }
if (found_user.refreshTokenCount !== decoded["refreshtokencount"]) { if (found_user.refreshTokenCount !== decoded["refreshtokencount"]) {
throw new RefreshTokenCountInvalidError() throw new RefreshTokenCountInvalidError()
} }
found_user.permissions = found_user.permissions || []
delete found_user.password; delete found_user.password;
const timestamp_accesstoken_expiry = Math.floor(Date.now() / 1000) + 5 * 60 const timestamp_accesstoken_expiry = Math.floor(Date.now() / 1000) + 5 * 60
delete found_user.password; delete found_user.password;