Merge branch 'dev' into feature/18-exported-env-vars
This commit is contained in:
@@ -6,7 +6,7 @@ import { config } from '../../config';
|
||||
import { InvalidCredentialsError, PasswordNeededError, UserNotFoundError } from '../../errors/AuthError';
|
||||
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
||||
import { User } from '../entities/User';
|
||||
import { Auth } from '../responses/Auth';
|
||||
import { Auth } from '../responses/ResponseAuth';
|
||||
|
||||
export class CreateAuth {
|
||||
@IsOptional()
|
||||
@@ -28,13 +28,14 @@ export class CreateAuth {
|
||||
if (!this.password) {
|
||||
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) {
|
||||
throw new UserNotFoundError()
|
||||
} else {
|
||||
const found_user = found_users[0]
|
||||
if (await argon2.verify(found_user.password, this.password + found_user.uuid)) {
|
||||
const timestamp_accesstoken_expiry = Math.floor(Date.now() / 1000) + 5 * 60
|
||||
found_user.permissions = found_user.permissions || []
|
||||
delete found_user.password;
|
||||
newAuth.access_token = jsonwebtoken.sign({
|
||||
userdetails: found_user,
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IsInt } from 'class-validator';
|
||||
import { getConnectionManager } from 'typeorm';
|
||||
import { RunnerGroupNotFoundError } from '../../errors/RunnerErrors';
|
||||
import { RunnerGroupNotFoundError } from '../../errors/RunnerGroupErrors';
|
||||
import { RunnerOrganisationWrongTypeError } from '../../errors/RunnerOrganisationErrors';
|
||||
import { RunnerTeamNeedsParentError } from '../../errors/RunnerTeamErrors';
|
||||
import { Runner } from '../entities/Runner';
|
||||
@@ -35,7 +35,12 @@ export class CreateRunnerTeam extends CreateRunnerGroup {
|
||||
let newRunnerTeam: RunnerTeam = new RunnerTeam();
|
||||
|
||||
newRunnerTeam.name = this.name;
|
||||
newRunnerTeam.parentGroup = await this.getParent();
|
||||
try {
|
||||
newRunnerTeam.parentGroup = await this.getParent();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
newRunnerTeam.contact = await this.getContact()
|
||||
|
||||
return newRunnerTeam;
|
||||
@@ -2,7 +2,8 @@ import * as argon2 from "argon2";
|
||||
import { IsEmail, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
|
||||
import { getConnectionManager } from 'typeorm';
|
||||
import * as uuid from 'uuid';
|
||||
import { UserGroupNotFoundError, UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
||||
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
||||
import { UserGroupNotFoundError } from '../../errors/UserGroupErrors';
|
||||
import { User } from '../entities/User';
|
||||
import { UserGroup } from '../entities/UserGroup';
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getConnectionManager } from 'typeorm';
|
||||
import { config } from '../../config';
|
||||
import { IllegalJWTError, JwtNotProvidedError, RefreshTokenCountInvalidError, UserNotFoundError } from '../../errors/AuthError';
|
||||
import { User } from '../entities/User';
|
||||
import { Logout } from '../responses/Logout';
|
||||
import { Logout } from '../responses/ResponseLogout';
|
||||
|
||||
export class HandleLogout {
|
||||
@IsString()
|
||||
@@ -4,7 +4,7 @@ import { getConnectionManager } from 'typeorm';
|
||||
import { config } from '../../config';
|
||||
import { IllegalJWTError, JwtNotProvidedError, RefreshTokenCountInvalidError, UserNotFoundError } from '../../errors/AuthError';
|
||||
import { User } from '../entities/User';
|
||||
import { Auth } from '../responses/Auth';
|
||||
import { Auth } from '../responses/ResponseAuth';
|
||||
|
||||
export class RefreshAuth {
|
||||
@IsString()
|
||||
@@ -21,13 +21,14 @@ export class RefreshAuth {
|
||||
} catch (error) {
|
||||
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) {
|
||||
throw new UserNotFoundError()
|
||||
}
|
||||
if (found_user.refreshTokenCount !== decoded["refreshtokencount"]) {
|
||||
throw new RefreshTokenCountInvalidError()
|
||||
}
|
||||
found_user.permissions = found_user.permissions || []
|
||||
delete found_user.password;
|
||||
const timestamp_accesstoken_expiry = Math.floor(Date.now() / 1000) + 5 * 60
|
||||
delete found_user.password;
|
||||
Reference in New Issue
Block a user