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 { 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';
/** /**
* Defines a admin user. * Defines a admin user.
@ -97,27 +96,14 @@ export class User {
@IsString() @IsString()
profilepic: string; profilepic: string;
/**
* actions
*/
@OneToMany(() => UserAction, action => action.user)
actions: UserAction
/** /**
* calculate all permissions * calculate all permissions
*/ */
public get calc_permissions(): Permission[] { public get calc_permissions(): Permission[] {
let final_permissions = [] let final_permissions = this.groups.forEach((permission) => {
this.groups.forEach((permission) => { console.log(permission);
if (!final_permissions.includes(permission)) {
final_permissions.push(permission)
}
}) })
this.permissions.forEach((permission) => { // TODO: add user permissions on top of group permissions + return
if (!final_permissions.includes(permission)) { return []
final_permissions.push(permission)
}
})
return final_permissions
} }
} }

View File

@ -1,11 +1,10 @@
import { PrimaryGeneratedColumn, Column, OneToMany, Entity, ManyToOne } from "typeorm"; import { PrimaryGeneratedColumn, Column, OneToMany, Entity } from "typeorm";
import { import {
IsInt, IsInt,
IsNotEmpty, IsNotEmpty,
IsOptional, IsOptional,
IsString, IsString,
} from "class-validator"; } from "class-validator";
import { User } from './User';
/** /**
* Defines the UserAction interface. * Defines the UserAction interface.
@ -20,11 +19,8 @@ export class UserAction {
@IsInt() @IsInt()
id: number; id: number;
/** // TODO:
* user // user: relation
*/
@ManyToOne(() => User, user => user.actions)
user: User
/** /**
* The actions's target (e.g. Track#2) * The actions's target (e.g. Track#2)