Compare commits

..

No commits in common. "36b2e82f4e8e2e4003f2e1ef91969bfbbb32f991" and "92bafb0cf457b50a19f0f965c3a7e241974e750d" have entirely different histories.

27 changed files with 140 additions and 156 deletions

View File

@ -8,5 +8,5 @@ export default {
username: process.env.DB_USER, username: process.env.DB_USER,
password: process.env.DB_PASSWORD, password: process.env.DB_PASSWORD,
database: process.env.DB_NAME, database: process.env.DB_NAME,
entities: ["src/models/entities/*.ts"] entities: ["src/models/*.ts"]
}; };

View File

@ -2,9 +2,9 @@ import { JsonController, Param, Body, Get, Post, Put, Delete, OnUndefined } from
import { getConnectionManager, Repository } from 'typeorm'; import { getConnectionManager, Repository } from 'typeorm';
import { EntityFromBody } from 'typeorm-routing-controllers-extensions'; import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { Runner } from '../models/entities/Runner'; import { Runner } from '../models/Runner';
import { RunnerGroupNeededError, RunnerGroupNotFoundError, RunnerIdsNotMatchingError, RunnerNotFoundError, RunnerOnlyOneGroupAllowedError } from '../errors/RunnerErrors'; import { RunnerGroupNeededError, RunnerGroupNotFoundError, RunnerIdsNotMatchingError, RunnerNotFoundError, RunnerOnlyOneGroupAllowedError } from '../errors/RunnerErrors';
import { CreateRunner } from '../models/creation/CreateRunner'; import { CreateRunner } from '../models/CreateRunner';
@JsonController('/runners') @JsonController('/runners')

View File

@ -2,10 +2,10 @@ import { JsonController, Param, Body, Get, Post, Put, Delete, OnUndefined } from
import { getConnectionManager, Repository } from 'typeorm'; import { getConnectionManager, Repository } from 'typeorm';
import { EntityFromBody } from 'typeorm-routing-controllers-extensions'; import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { RunnerOrganisation } from '../models/entities/RunnerOrganisation'; import { RunnerOrganisation } from '../models/RunnerOrganisation';
import { RunnerOrganisationIdsNotMatchingError, RunnerOrganisationNotFoundError } from '../errors/RunnerOrganisationErrors'; import { RunnerOrganisationIdsNotMatchingError, RunnerOrganisationNotFoundError } from '../errors/RunnerOrganisationErrors';
import { CreateRunnerOrganisation } from '../models/creation/CreateRunnerOrganisation'; import { CreateRunnerOrganisation } from '../models/CreateRunnerOrganisation';
import { RunnerGroup } from '../models/entities/RunnerGroup'; import { RunnerGroup } from '../models/RunnerGroup';
@JsonController('/organisations') @JsonController('/organisations')

View File

@ -2,10 +2,10 @@ import { JsonController, Param, Body, Get, Post, Put, Delete, NotFoundError, OnU
import { getConnectionManager, Repository } from 'typeorm'; import { getConnectionManager, Repository } from 'typeorm';
import { EntityFromBody } from 'typeorm-routing-controllers-extensions'; import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { Track } from '../models/entities/Track'; import { Track } from '../models/Track';
import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator'; import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator';
import { TrackIdsNotMatchingError, TrackNotFoundError } from "../errors/TrackErrors"; import { TrackIdsNotMatchingError, TrackNotFoundError } from "../errors/TrackErrors";
import { CreateTrack } from '../models/creation/CreateTrack'; import { CreateTrack } from '../models/CreateTrack';
@JsonController('/tracks') @JsonController('/tracks')
//@Authorized("TRACKS:read") //@Authorized("TRACKS:read")

View File

@ -1,11 +1,11 @@
import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsPositive, IsString } from 'class-validator'; import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsPositive, IsString } from 'class-validator';
import { Runner } from '../entities/Runner'; import { Runner } from '../models/Runner';
import { getConnectionManager, Repository } from 'typeorm'; import { getConnectionManager, Repository } from 'typeorm';
import { group } from 'console'; import { group } from 'console';
import { RunnerOnlyOneGroupAllowedError, RunnerGroupNeededError, RunnerGroupNotFoundError } from '../../errors/RunnerErrors'; import { RunnerOnlyOneGroupAllowedError, RunnerGroupNeededError, RunnerGroupNotFoundError } from '../errors/RunnerErrors';
import { RunnerOrganisation } from '../entities/RunnerOrganisation'; import { RunnerOrganisation } from './RunnerOrganisation';
import { RunnerTeam } from '../entities/RunnerTeam'; import { RunnerTeam } from './RunnerTeam';
import { RunnerGroup } from '../entities/RunnerGroup'; import { RunnerGroup } from './RunnerGroup';
import { Address } from 'cluster'; import { Address } from 'cluster';
export class CreateRunner { export class CreateRunner {

View File

@ -1,5 +1,5 @@
import { IsString } from 'class-validator'; import { IsString } from 'class-validator';
import { RunnerOrganisation } from '../entities/RunnerOrganisation'; import { RunnerOrganisation } from './RunnerOrganisation';
export class CreateRunnerOrganisation { export class CreateRunnerOrganisation {
@IsString() @IsString()

View File

@ -1,5 +1,5 @@
import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator'; import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator';
import { Track } from '../entities/Track'; import { Track } from './Track';
export class CreateTrack { export class CreateTrack {
/** /**

View File

@ -1,7 +1,6 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany } from "typeorm"; import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany } from "typeorm";
import { import {
IsBoolean, IsBoolean,
IsEAN,
IsInt, IsInt,
IsNotEmpty, IsNotEmpty,
IsOptional, IsOptional,
@ -33,12 +32,12 @@ export class RunnerCard {
/** /**
* The card's code. * The card's code.
* This has to be able to being converted to something barcode compatible. * This has to be able to being converted to something barcode compatible.
* could theoretically be autogenerated * Probably gonna be autogenerated.
*/ */
@Column() @Column()
@IsEAN()
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()
//TODO: Generate this
code: string; code: string;
/** /**

View File

@ -43,12 +43,4 @@ export abstract class Scan {
@Column() @Column()
@IsBoolean() @IsBoolean()
valid: boolean = true; valid: boolean = true;
/**
* seconds since last scan
*/
@IsInt()
@IsOptional()
secondsSinceLastScan: number;
} }

View File

@ -1,130 +1,123 @@
import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique, JoinTable, ManyToMany } from "typeorm"; import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique, JoinTable, ManyToMany } from "typeorm";
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString, isUUID, } from "class-validator"; import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsString, isUUID, } from "class-validator";
import { UserGroup } from './UserGroup'; import { UserGroup } from './UserGroup';
import { Permission } from './Permission'; import { Permission } from './Permission';
import { UserAction } from './UserAction'; import { UserAction } from './UserAction';
/** /**
* Defines a admin user. * Defines a admin user.
*/ */
@Entity() @Entity()
export class User { export class User {
/** /**
* autogenerated unique id (primary key). * autogenerated unique id (primary key).
*/ */
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
@IsOptional() @IsOptional()
@IsInt() @IsInt()
id: number; id: number;
/** /**
* autogenerated uuid * autogenerated uuid
*/ */
@IsOptional() @IsOptional()
@IsInt() @IsInt()
@Generated("uuid") @Generated("uuid")
uuid: string; uuid: string;
/** /**
* user email * user email
*/ */
@IsEmail() @IsEmail()
email: string; email: string;
/** /**
* user phone * username
*/ */
@IsPhoneNumber("ZZ") @IsString()
@IsOptional() username: string;
phone: string;
/**
/** * firstname
* username */
*/ @IsString()
@IsString() @IsNotEmpty()
username: string; firstname: string;
/** /**
* firstname * middlename
*/ */
@IsString() @IsString()
@IsNotEmpty() @IsOptional()
firstname: string; middlename: string;
/** /**
* middlename * lastname
*/ */
@IsString() @IsString()
@IsOptional() @IsNotEmpty()
middlename: string; lastname: string;
/** /**
* lastname * password
*/ */
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()
lastname: string; password: string;
/** /**
* password * permissions
*/ */
@IsString() @ManyToOne(() => Permission, permission => permission.users, { nullable: true })
@IsNotEmpty() permissions: Permission[];
password: string;
/**
/** * groups
* permissions */
*/ @ManyToMany(() => UserGroup)
@ManyToOne(() => Permission, permission => permission.users, { nullable: true }) @JoinTable()
permissions: Permission[]; groups: UserGroup[];
/** /**
* groups * is user enabled?
*/ */
@ManyToMany(() => UserGroup) @IsBoolean()
@JoinTable() enabled: boolean;
groups: UserGroup[];
/**
/** * jwt refresh count
* is user enabled? */
*/ @IsInt()
@IsBoolean() @Column({ default: 1 })
enabled: boolean; refreshTokenCount: number;
/** /**
* jwt refresh count * profilepic
*/ */
@IsInt() @IsString()
@Column({ default: 1 }) profilepic: string;
refreshTokenCount: number;
/**
/** * actions
* profilepic */
*/ @OneToMany(() => UserAction, action => action.user)
@IsString() actions: UserAction
profilepic: string;
/**
/** * calculate all permissions
* actions */
*/ public get calc_permissions(): Permission[] {
@OneToMany(() => UserAction, action => action.user) let final_permissions = []
actions: UserAction this.groups.forEach((permission) => {
if (!final_permissions.includes(permission)) {
/** final_permissions.push(permission)
* calculate all permissions }
*/ })
public get calc_permissions(): Permission[] { this.permissions.forEach((permission) => {
let final_permissions = [] if (!final_permissions.includes(permission)) {
this.groups.forEach((permission) => { final_permissions.push(permission)
if (!final_permissions.includes(permission)) { }
final_permissions.push(permission) })
} return final_permissions
}) }
this.permissions.forEach((permission) => { }
if (!final_permissions.includes(permission)) {
final_permissions.push(permission)
}
})
return final_permissions
}
}