diff --git a/src/models/actions/CreateGroupContact.ts b/src/models/actions/CreateGroupContact.ts
index 5f49879..747f29d 100644
--- a/src/models/actions/CreateGroupContact.ts
+++ b/src/models/actions/CreateGroupContact.ts
@@ -56,7 +56,7 @@ export class CreateGroupContact {
* Get's this participant's address from this.address.
*/
public async getAddress(): Promise
{
- if (this.address === undefined) {
+ if (this.address === undefined || this.address === null) {
return null;
}
if (!isNaN(this.address)) {
diff --git a/src/models/actions/CreateParticipant.ts b/src/models/actions/CreateParticipant.ts
index b3827d1..49cba30 100644
--- a/src/models/actions/CreateParticipant.ts
+++ b/src/models/actions/CreateParticipant.ts
@@ -58,7 +58,7 @@ export abstract class CreateParticipant {
* Get's this participant's address from this.address.
*/
public async getAddress(): Promise {
- if (this.address === undefined) {
+ if (this.address === undefined || this.address === null) {
return null;
}
if (!isNaN(this.address)) {
diff --git a/src/models/actions/CreateRunner.ts b/src/models/actions/CreateRunner.ts
index 2b9f128..28ccaae 100644
--- a/src/models/actions/CreateRunner.ts
+++ b/src/models/actions/CreateRunner.ts
@@ -36,7 +36,7 @@ export class CreateRunner extends CreateParticipant {
* Manages all the different ways a group can be provided.
*/
public async getGroup(): Promise {
- if (this.group === undefined) {
+ if (this.group === undefined || this.group === null) {
throw new RunnerTeamNeedsParentError();
}
if (!isNaN(this.group)) {
diff --git a/src/models/actions/CreateRunnerOrganisation.ts b/src/models/actions/CreateRunnerOrganisation.ts
index 46fc72e..ffef4a3 100644
--- a/src/models/actions/CreateRunnerOrganisation.ts
+++ b/src/models/actions/CreateRunnerOrganisation.ts
@@ -19,7 +19,7 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
* Get's this org's address from this.address.
*/
public async getAddress(): Promise {
- if (this.address === undefined) {
+ if (this.address === undefined || this.address === null) {
return null;
}
if (!isNaN(this.address)) {
diff --git a/src/models/actions/CreateRunnerTeam.ts b/src/models/actions/CreateRunnerTeam.ts
index 0a4941f..0a6f992 100644
--- a/src/models/actions/CreateRunnerTeam.ts
+++ b/src/models/actions/CreateRunnerTeam.ts
@@ -16,7 +16,7 @@ export class CreateRunnerTeam extends CreateRunnerGroup {
parentGroup: number;
public async getParent(): Promise {
- if (this.parentGroup === undefined) {
+ if (this.parentGroup === undefined || this.parentGroup === null) {
throw new RunnerTeamNeedsParentError();
}
if (!isNaN(this.parentGroup)) {
diff --git a/src/models/actions/UpdatePermission.ts b/src/models/actions/UpdatePermission.ts
index dec0ad8..8c31bbe 100644
--- a/src/models/actions/UpdatePermission.ts
+++ b/src/models/actions/UpdatePermission.ts
@@ -49,7 +49,7 @@ export class UpdatePermission {
* Manages all the different ways a group can be provided.
*/
public async getPrincipal(): Promise {
- if (this.principal === undefined) {
+ if (this.principal === undefined || this.principal === null) {
throw new PermissionNeedsPrincipalError();
}
if (!isNaN(this.principal.id)) {
diff --git a/src/models/actions/UpdateRunner.ts b/src/models/actions/UpdateRunner.ts
index cd38961..62667ec 100644
--- a/src/models/actions/UpdateRunner.ts
+++ b/src/models/actions/UpdateRunner.ts
@@ -40,7 +40,7 @@ export class UpdateRunner extends CreateParticipant {
* Manages all the different ways a group can be provided.
*/
public async getGroup(): Promise {
- if (this.group === undefined) {
+ if (this.group === undefined || this.group === null) {
throw new RunnerTeamNeedsParentError();
}
if (!isNaN(this.group.id)) {
diff --git a/src/models/actions/UpdateRunnerOrganisation.ts b/src/models/actions/UpdateRunnerOrganisation.ts
index 19d5d34..6917698 100644
--- a/src/models/actions/UpdateRunnerOrganisation.ts
+++ b/src/models/actions/UpdateRunnerOrganisation.ts
@@ -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 {
- 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;
}
/**
diff --git a/src/models/actions/UpdateRunnerTeam.ts b/src/models/actions/UpdateRunnerTeam.ts
index 8eaee39..62b71d5 100644
--- a/src/models/actions/UpdateRunnerTeam.ts
+++ b/src/models/actions/UpdateRunnerTeam.ts
@@ -22,7 +22,7 @@ export class UpdateRunnerTeam extends CreateRunnerGroup {
parentGroup: RunnerOrganisation;
public async getParent(): Promise {
- if (this.parentGroup === undefined) {
+ if (this.parentGroup === undefined || this.parentGroup === null) {
throw new RunnerTeamNeedsParentError();
}
if (!isNaN(this.parentGroup.id)) {
diff --git a/src/models/actions/UpdateUser.ts b/src/models/actions/UpdateUser.ts
index 14d3ca8..f91e7a5 100644
--- a/src/models/actions/UpdateUser.ts
+++ b/src/models/actions/UpdateUser.ts
@@ -88,7 +88,7 @@ export class UpdateUser {
public async updateUser(user: User): Promise {
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) {