Compare commits

..

No commits in common. "1cf35f016b0aeb0f1224648b301044b2ea76dc60" and "aa565c6b344f62521b9b53575ffce36e8b77af74" have entirely different histories.

2 changed files with 38 additions and 56 deletions

View File

@ -2,7 +2,6 @@ import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsString, isUUID, } from "class-validator";
import { UserGroup } from './UserGroup';
import { Permission } from './Permission';
import { UserAction } from './UserAction';
/**
* Defines a admin user.
@ -97,27 +96,14 @@ export class User {
@IsString()
profilepic: string;
/**
* actions
*/
@OneToMany(() => UserAction, action => action.user)
actions: UserAction
/**
* calculate all permissions
*/
public get calc_permissions(): Permission[] {
let final_permissions = []
this.groups.forEach((permission) => {
if (!final_permissions.includes(permission)) {
final_permissions.push(permission)
}
let final_permissions = this.groups.forEach((permission) => {
console.log(permission);
})
this.permissions.forEach((permission) => {
if (!final_permissions.includes(permission)) {
final_permissions.push(permission)
}
})
return final_permissions
// TODO: add user permissions on top of group permissions + return
return []
}
}

View File

@ -1,11 +1,10 @@
import { PrimaryGeneratedColumn, Column, OneToMany, Entity, ManyToOne } from "typeorm";
import { PrimaryGeneratedColumn, Column, OneToMany, Entity } from "typeorm";
import {
IsInt,
IsNotEmpty,
IsOptional,
IsString,
} from "class-validator";
import { User } from './User';
/**
* Defines the UserAction interface.
@ -20,11 +19,8 @@ export class UserAction {
@IsInt()
id: number;
/**
* user
*/
@ManyToOne(() => User, user => user.actions)
user: User
// TODO:
// user: relation
/**
* The actions's target (e.g. Track#2)
@ -45,7 +41,7 @@ export class UserAction {
/**
* The description of change (before-> after; e.g. distance:15->17)
*/
@Column({ nullable: true })
@Column({nullable: true})
@IsOptional()
@IsString()
changed: string;