Fixed some stuff not getting checked against null
ref #39 gosh i sometimes hate js types
This commit is contained in:
		@@ -56,7 +56,7 @@ export class CreateGroupContact {
 | 
			
		||||
     * Get's this participant's address from this.address.
 | 
			
		||||
     */
 | 
			
		||||
    public async getAddress(): Promise<Address> {
 | 
			
		||||
        if (this.address === undefined) {
 | 
			
		||||
        if (this.address === undefined || this.address === null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (!isNaN(this.address)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,7 @@ export abstract class CreateParticipant {
 | 
			
		||||
     * Get's this participant's address from this.address.
 | 
			
		||||
     */
 | 
			
		||||
    public async getAddress(): Promise<Address> {
 | 
			
		||||
        if (this.address === undefined) {
 | 
			
		||||
        if (this.address === undefined || this.address === null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (!isNaN(this.address)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ export class CreateRunner extends CreateParticipant {
 | 
			
		||||
     * Manages all the different ways a group can be provided.
 | 
			
		||||
     */
 | 
			
		||||
    public async getGroup(): Promise<RunnerGroup> {
 | 
			
		||||
        if (this.group === undefined) {
 | 
			
		||||
        if (this.group === undefined || this.group === null) {
 | 
			
		||||
            throw new RunnerTeamNeedsParentError();
 | 
			
		||||
        }
 | 
			
		||||
        if (!isNaN(this.group)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
 | 
			
		||||
     * Get's this org's address from this.address.
 | 
			
		||||
     */
 | 
			
		||||
    public async getAddress(): Promise<Address> {
 | 
			
		||||
        if (this.address === undefined) {
 | 
			
		||||
        if (this.address === undefined || this.address === null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (!isNaN(this.address)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ export class CreateRunnerTeam extends CreateRunnerGroup {
 | 
			
		||||
    parentGroup: number;
 | 
			
		||||
 | 
			
		||||
    public async getParent(): Promise<RunnerOrganisation> {
 | 
			
		||||
        if (this.parentGroup === undefined) {
 | 
			
		||||
        if (this.parentGroup === undefined || this.parentGroup === null) {
 | 
			
		||||
            throw new RunnerTeamNeedsParentError();
 | 
			
		||||
        }
 | 
			
		||||
        if (!isNaN(this.parentGroup)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ export class UpdatePermission {
 | 
			
		||||
     * Manages all the different ways a group can be provided.
 | 
			
		||||
     */
 | 
			
		||||
    public async getPrincipal(): Promise<Principal> {
 | 
			
		||||
        if (this.principal === undefined) {
 | 
			
		||||
        if (this.principal === undefined || this.principal === null) {
 | 
			
		||||
            throw new PermissionNeedsPrincipalError();
 | 
			
		||||
        }
 | 
			
		||||
        if (!isNaN(this.principal.id)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ export class UpdateRunner extends CreateParticipant {
 | 
			
		||||
     * Manages all the different ways a group can be provided.
 | 
			
		||||
     */
 | 
			
		||||
    public async getGroup(): Promise<RunnerGroup> {
 | 
			
		||||
        if (this.group === undefined) {
 | 
			
		||||
        if (this.group === undefined || this.group === null) {
 | 
			
		||||
            throw new RunnerTeamNeedsParentError();
 | 
			
		||||
        }
 | 
			
		||||
        if (!isNaN(this.group.id)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import { IsInt, IsOptional } from 'class-validator';
 | 
			
		||||
import { getConnectionManager } from 'typeorm';
 | 
			
		||||
import { AddressNotFoundError, AddressWrongTypeError } from '../../errors/AddressErrors';
 | 
			
		||||
import { AddressNotFoundError } from '../../errors/AddressErrors';
 | 
			
		||||
import { Address } from '../entities/Address';
 | 
			
		||||
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
 | 
			
		||||
import { CreateRunnerGroup } from './CreateRunnerGroup';
 | 
			
		||||
@@ -20,22 +20,18 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup {
 | 
			
		||||
     */
 | 
			
		||||
    @IsInt()
 | 
			
		||||
    @IsOptional()
 | 
			
		||||
    address?: number;
 | 
			
		||||
    address?: Address;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get's this org's address from this.address.
 | 
			
		||||
     */
 | 
			
		||||
    public async getAddress(): Promise<Address> {
 | 
			
		||||
        if (this.address === undefined) {
 | 
			
		||||
        if (this.address === undefined || this.address === null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (!isNaN(this.address)) {
 | 
			
		||||
            let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
 | 
			
		||||
            if (!address) { throw new AddressNotFoundError; }
 | 
			
		||||
            return address;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new AddressWrongTypeError;
 | 
			
		||||
        let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address.id });
 | 
			
		||||
        if (!address) { throw new AddressNotFoundError; }
 | 
			
		||||
        return address;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ export class UpdateRunnerTeam extends CreateRunnerGroup {
 | 
			
		||||
    parentGroup: RunnerOrganisation;
 | 
			
		||||
 | 
			
		||||
    public async getParent(): Promise<RunnerOrganisation> {
 | 
			
		||||
        if (this.parentGroup === undefined) {
 | 
			
		||||
        if (this.parentGroup === undefined || this.parentGroup === null) {
 | 
			
		||||
            throw new RunnerTeamNeedsParentError();
 | 
			
		||||
        }
 | 
			
		||||
        if (!isNaN(this.parentGroup.id)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -88,7 +88,7 @@ export class UpdateUser {
 | 
			
		||||
    public async updateUser(user: User): Promise<User> {
 | 
			
		||||
        user.email = this.email;
 | 
			
		||||
        user.username = this.username;
 | 
			
		||||
        if (user.email === undefined && user.username === undefined) {
 | 
			
		||||
        if ((user.email === undefined || user.email === null) && (user.username === undefined || user.username === null)) {
 | 
			
		||||
            throw new UsernameOrEmailNeededError();
 | 
			
		||||
        }
 | 
			
		||||
        if (this.password) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user