Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
IQB
PersonalDB
Commits
8d444326
Commit
8d444326
authored
Feb 13, 2022
by
mechtelm
Browse files
Show staff list
parent
f3be6095
Changes
38
Hide whitespace changes
Inline
Side-by-side
.idea/personaldb.iml
View file @
8d444326
...
...
@@ -5,6 +5,8 @@
<content
url=
"file://$MODULE_DIR$"
>
<excludeFolder
url=
"file://$MODULE_DIR$/personaldb/dist"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/personaldb/tmp"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/dist"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/tmp"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
...
...
apps/api/src/app/app-admin/is-admin.guard.ts
View file @
8d444326
...
...
@@ -12,7 +12,7 @@ export class IsAdminGuard implements CanActivate {
)
{
const
req
=
context
.
switchToHttp
().
getRequest
();
const
userId
=
req
.
user
.
id
;
const
isAdmin
=
await
this
.
authService
.
isAdminUser
(
userId
);
const
isAdmin
=
await
this
.
authService
.
isA
ppA
dminUser
(
userId
);
if
(
!
isAdmin
)
{
throw
new
UnauthorizedException
();
}
...
...
apps/api/src/app/app.controller.ts
View file @
8d444326
...
...
@@ -37,12 +37,8 @@ export class AppController {
type
:
AuthDataDto
,
})
@
ApiTags
(
'
auth
'
)
async
findCanDos
(@
UserId
()
userId
:
number
,
@
UserName
()
userName
:
string
):
Promise
<
AuthDataDto
>
{
return
<
AuthDataDto
>
{
userId
:
userId
,
userName
:
userName
,
isAppAdmin
:
await
this
.
authService
.
isAdminUser
(
userId
)
}
async
findCanDos
(@
UserId
()
userId
:
number
):
Promise
<
AuthDataDto
>
{
return
await
this
.
authService
.
getCanDos
(
userId
)
}
@
Patch
(
'
password
'
)
...
...
apps/api/src/app/auth/service/auth.service.ts
View file @
8d444326
import
{
Injectable
}
from
'
@nestjs/common
'
;
import
{
JwtService
}
from
"
@nestjs/jwt
"
;
import
{
UsersService
}
from
"
../../database/services/users.service
"
;
import
{
AuthDataDto
}
from
"
../../../../../../libs/dto/src
"
;
@
Injectable
()
export
class
AuthService
{
...
...
@@ -18,9 +19,23 @@ export class AuthService {
return
this
.
jwtService
.
sign
(
payload
);
}
async
isAdminUser
(
userId
:
number
):
Promise
<
boolean
>
{
const
isAdmin
=
await
this
.
usersService
.
getUserIsAppAdmin
(
userId
);
return
isAdmin
?
isAdmin
:
false
;
async
isAppAdminUser
(
userId
:
number
):
Promise
<
boolean
>
{
const
canDos
=
await
this
.
usersService
.
getCanDos
(
userId
);
return
canDos
?
canDos
.
isAppAdmin
:
false
;
}
async
isPersonalAdminUser
(
userId
:
number
):
Promise
<
boolean
>
{
const
canDos
=
await
this
.
usersService
.
getCanDos
(
userId
);
return
canDos
?
canDos
.
isPersonalAdmin
:
false
;
}
async
isCmsAdminUser
(
userId
:
number
):
Promise
<
boolean
>
{
const
canDos
=
await
this
.
usersService
.
getCanDos
(
userId
);
return
canDos
?
canDos
.
isCmsAdmin
:
false
;
}
async
getCanDos
(
userId
:
number
):
Promise
<
AuthDataDto
>
{
return
await
this
.
usersService
.
getCanDos
(
userId
);
}
async
getMyName
(
id
:
number
):
Promise
<
string
>
{
...
...
apps/api/src/app/database/services/users.service.ts
View file @
8d444326
...
...
@@ -4,7 +4,7 @@ import {InjectRepository} from "@nestjs/typeorm";
import
User
from
"
../entities/user.entity
"
;
import
*
as
bcrypt
from
'
bcrypt
'
;
import
{
passwordHash
}
from
"
../../auth/auth.constants
"
;
import
{
CreateUserDto
,
UserFullDto
,
UserInListDto
}
from
"
../../../../../../libs/dto/src
"
;
import
{
AuthDataDto
,
CreateUserDto
,
UserFullDto
,
UserInListDto
}
from
"
../../../../../../libs/dto/src
"
;
@
Injectable
()
export
class
UsersService
{
...
...
@@ -61,7 +61,7 @@ export class UsersService {
return
null
}
async
get
UserIsAppAdmin
(
userId
:
number
):
Promise
<
boolean
|
null
>
{
async
get
CanDos
(
userId
:
number
):
Promise
<
AuthDataDto
|
null
>
{
const
user
=
await
getConnection
()
.
getRepository
(
User
)
.
createQueryBuilder
(
"
user
"
)
...
...
@@ -69,7 +69,13 @@ export class UsersService {
{
id
:
userId
})
.
getOne
();
if
(
user
)
{
return
user
.
isAppAdmin
return
<
AuthDataDto
>
{
userId
:
userId
,
userName
:
user
.
name
,
isAppAdmin
:
user
.
isAppAdmin
,
isPersonalAdmin
:
user
.
isPersonalAdmin
,
isCmsAdmin
:
user
.
isCmsAdmin
}
}
return
null
}
...
...
apps/frontend/src/app/app-admin/admin.module.ts
→
apps/frontend/src/app/app-admin/
app-
admin.module.ts
View file @
8d444326
...
...
@@ -86,4 +86,4 @@ import {IqbComponentsModule} from "../../../../../libs/iqb-components/src";
EditUserComponent
]
})
export
class
AdminModule
{
}
export
class
App
AdminModule
{
}
apps/frontend/src/app/app-admin/index.ts
View file @
8d444326
export
{
AdminComponent
}
from
'
./admin.component
'
;
export
{
AdminModule
}
from
'
./admin.module
'
;
export
{
App
AdminModule
}
from
'
./
app-
admin.module
'
;
apps/frontend/src/app/app-admin/users/users.component.ts
View file @
8d444326
...
...
@@ -149,8 +149,8 @@ export class UsersComponent implements OnInit {
if
(
newDescription
!==
selectedRows
[
0
].
description
)
changedData
.
description
=
newDescription
;
if
(
newPassword
)
changedData
.
password
=
newPassword
;
if
(
newIsAppAdmin
!==
selectedRows
[
0
].
isAppAdmin
)
changedData
.
isAppAdmin
=
newIsAppAdmin
;
if
(
newIsPersonalAdmin
!==
selectedRows
[
0
].
is
App
Admin
)
changedData
.
isPersonalAdmin
=
newIsPersonalAdmin
;
if
(
newIsCmsAdmin
!==
selectedRows
[
0
].
is
App
Admin
)
changedData
.
isCmsAdmin
=
newIsCmsAdmin
;
if
(
newIsPersonalAdmin
!==
selectedRows
[
0
].
is
Personal
Admin
)
changedData
.
isPersonalAdmin
=
newIsPersonalAdmin
;
if
(
newIsCmsAdmin
!==
selectedRows
[
0
].
is
Cms
Admin
)
changedData
.
isCmsAdmin
=
newIsCmsAdmin
;
this
.
backendService
.
changeUserData
(
changedData
).
subscribe
(
respOk
=>
{
this
.
updateUserList
();
...
...
apps/frontend/src/app/app-routing.module.ts
View file @
8d444326
...
...
@@ -8,8 +8,16 @@ const routes: Routes = [
{
path
:
'
home
'
,
component
:
HomeComponent
},
{
path
:
'
about
'
,
component
:
AboutComponent
},
{
path
:
'
admin
'
,
loadChildren
:
()
=>
import
(
'
./app-admin/admin.module
'
).
then
(
module
=>
module
.
AdminModule
)
path
:
'
app-admin
'
,
loadChildren
:
()
=>
import
(
'
./app-admin/app-admin.module
'
).
then
(
module
=>
module
.
AppAdminModule
)
},
{
path
:
'
personal-admin
'
,
loadChildren
:
()
=>
import
(
'
./personal-admin/personal-admin.module
'
).
then
(
module
=>
module
.
PersonalAdminModule
)
},
{
path
:
'
staff
'
,
loadChildren
:
()
=>
import
(
'
./staff-list/staff-list.module
'
).
then
(
module
=>
module
.
StaffListModule
)
}
];
...
...
apps/frontend/src/app/home/home.component.css
View file @
8d444326
...
...
@@ -10,6 +10,7 @@
.box-right
,
.box-left
{
padding
:
20px
;
margin
:
10px
;
min-height
:
300px
;
}
.box-right
{
...
...
apps/frontend/src/app/home/home.component.html
View file @
8d444326
<div
class=
"home-body"
fxLayout=
"row"
fxLayoutAlign=
"center stretch"
>
<div
fx
Flex=
"0 0 500px"
fxLayout=
"column"
*ngIf=
"appService.authData.userId === 0"
class=
"box-left
"
>
<!-- - - - - - - - - - - - - - - - - --
>
<div
class=
"home-body"
>
<div
fx
Layout=
"row"
fxLayoutAlign=
"center stretch
"
>
<mat-card
fxFlex=
"0 0 400px"
*ngIf=
"appService.authData.userId === 0"
class=
"box-left"
>
<form
[formGroup]=
"loginForm"
(ngSubmit)=
"login()"
>
<h1>
Anmelden
</h1>
<h2
*ngIf=
"appService.globalWarning"
class=
"warning"
>
{{appService.globalWarning}}
</h2>
<div
fxLayout=
"column"
>
<mat-form-field
class=
"full-width"
>
<input
matInput
formControlName=
"name"
placeholder=
"Anmeldename"
(keyup.enter)=
"pw.focus()"
>
</mat-form-field>
<mat-form-field
class=
"full-width"
>
<input
matInput
#pw
type=
"password"
formControlName=
"pw"
placeholder=
"Kennwort"
(keyup.enter)=
"login()"
>
</mat-form-field>
</div>
<p
*ngIf=
"errorMessage"
class=
"error-message"
>
{{errorMessage}}
</p>
<button
mat-raised-button
type=
"submit"
[disabled]=
"loginForm.invalid"
color=
"primary"
>
Weiter
</button>
<mat-card-title>
Anmelden
</mat-card-title>
<mat-card-content>
<h2
*ngIf=
"appService.globalWarning"
class=
"warning"
>
{{appService.globalWarning}}
</h2>
<div
fxLayout=
"column"
>
<mat-form-field
class=
"full-width"
>
<input
matInput
formControlName=
"name"
placeholder=
"Anmeldename"
(keyup.enter)=
"pw.focus()"
>
</mat-form-field>
<mat-form-field
class=
"full-width"
>
<input
matInput
#pw
type=
"password"
formControlName=
"pw"
placeholder=
"Kennwort"
(keyup.enter)=
"login()"
>
</mat-form-field>
</div>
<p
*ngIf=
"errorMessage"
class=
"error-message"
>
{{errorMessage}}
</p>
</mat-card-content>
<mat-card-actions>
<button
mat-raised-button
type=
"submit"
[disabled]=
"loginForm.invalid"
color=
"primary"
>
Weiter
</button>
</mat-card-actions>
</form>
</
div
>
</
mat-card
>
<div
fxFlex=
"0 0 500px"
fxLayout=
"column"
class=
"box-left"
*ngIf=
"appService.authData.userId > 0"
>
<h1
fxLayout=
"row"
fxLayoutAlign=
"space-between center"
>
Arbeitsbereich wählen
<button
mat-button
*ngIf=
"appService.authData.isAppAdmin"
[routerLink]=
"['/admin']"
matTooltip=
"Nutzer/Arbeitsbereiche"
>
<mat-card
fxFlex=
"0 0 400px"
fxLayout=
"column"
class=
"box-left"
*ngIf=
"appService.authData.userId > 0"
>
<mat-card-title
fxLayout=
"row"
fxLayoutAlign=
"space-between center"
>
Bitte wählen
<button
mat-button
*ngIf=
"appService.authData.isAppAdmin"
[routerLink]=
"['/app-admin']"
matTooltip=
"Systemeinstellungen"
>
<mat-icon>
settings
</mat-icon>
</button>
<button
mat-button
*ngIf=
"appService.authData.isPersonalAdmin"
[routerLink]=
"['/personal-admin']"
matTooltip=
"Einstellungen Personal"
>
<mat-icon>
settings
</mat-icon>
</button>
</h1>
<h2
*ngIf=
"appService.globalWarning"
class=
"warning"
>
{{appService.globalWarning}}
</h2>
</mat-card-title>
<mat-card-content>
<h2
*ngIf=
"appService.globalWarning"
class=
"warning"
>
{{appService.globalWarning}}
</h2>
<button
mat-raised-button
color=
"primary"
[routerLink]=
"['/staff']"
>
Personal-Daten
</button>
</mat-card-content>
<
div
fxLayout=
"row"
fxLayoutAlign=
"space-between center"
>
<button
mat-raised-button
color=
"foreground"
(click)=
"changePassword()"
matTooltip=
"Kennwort ändern"
>
<
mat-card-actions
fxLayout=
"row"
fxLayoutAlign=
"space-between center"
>
<button
mat-raised-button
(click)=
"changePassword()"
matTooltip=
"Kennwort ändern"
>
<mat-icon>
account_box
</mat-icon>
Kennwort ändern
</button>
<button
mat-raised-button
color=
"foreground"
(click)=
"logout()"
matTooltip=
"Abmelden/Neu anmelden"
>
<button
mat-raised-button
(click)=
"logout()"
matTooltip=
"Abmelden/Neu anmelden"
>
<mat-icon>
logout
</mat-icon>
Abmelden
</button>
</
div
>
</
div
>
</
mat-card-actions
>
</
mat-card
>
<div
fxFlex=
"0 2 500px"
fxLayout=
"column"
class=
"box-right"
>
<h1>
{{appService.appConfig?.appTitle}}
</h1>
<div
[innerHTML]=
"appService.appConfig?.introHtml"
class=
"scroll-area"
></div>
<div
*ngIf=
"appService.authData.userId === 0"
>
<ul>
<li>
Kennung der Anwendung: {{appName}}
</li>
<li>
Version: {{appVersion}}
</li>
<li>
angemeldet als: {{ appService.authData.userName }}
</li>
<li
*ngIf=
"appService.authData.isAppAdmin"
>
Berechtigung zum Ändern von Nutzerrechten und Arbeitsbereichen
</li>
</ul>
</div>
<button
mat-raised-button
color=
"foreground"
[routerLink]=
"['/about']"
>
Impressum/Datenschutz
</button>
</div>
<mat-card
fxFlex=
"0 2 400px"
fxLayout=
"column"
class=
"box-right"
>
<mat-card-title>
{{appService.appConfig?.appTitle}}
</mat-card-title>
<mat-card-content>
<div
[innerHTML]=
"appService.appConfig?.introHtml"
class=
"scroll-area"
></div>
<div
*ngIf=
"appService.authData.userId === 0"
>
<ul>
<li>
Kennung der Anwendung: {{appName}}
</li>
<li>
Version: {{appVersion}}
</li>
<li>
angemeldet als: {{ appService.authData.userName }}
</li>
<li
*ngIf=
"appService.authData.isAppAdmin"
>
Berechtigung zum Ändern von Nutzerrechten und Arbeitsbereichen
</li>
<li
*ngIf=
"appService.authData.isPersonalAdmin"
>
Berechtigung zum Ändern von Einstellungen für Personaldaten
</li>
<li
*ngIf=
"appService.authData.isCmsAdmin"
>
Berechtigung zur Übernahme in das IDM der HU
</li>
</ul>
</div>
</mat-card-content>
<mat-card-actions>
<button
mat-raised-button
color=
"primary"
[routerLink]=
"['/about']"
>
Impressum/Datenschutz
</button>
</mat-card-actions>
</mat-card>
</div>
</div>
apps/frontend/src/app/home/home.component.ts
View file @
8d444326
...
...
@@ -63,6 +63,10 @@ export class HomeComponent implements OnInit, OnDestroy {
console
.
log
(
this
.
redirectTo
);
if
(
this
.
redirectTo
)
{
this
.
router
.
navigate
([
this
.
redirectTo
]);
}
else
{
if
(
this
.
appService
.
authData
.
isAppAdmin
||
this
.
appService
.
authData
.
isPersonalAdmin
||
this
.
appService
.
authData
.
isCmsAdmin
)
{
this
.
router
.
navigate
([
'
/staff
'
]);
}
}
},
err
=>
{
...
...
apps/frontend/src/app/personal-admin/personal-admin.component.html
0 → 100644
View file @
8d444326
<p>
personal-admin works!
</p>
apps/frontend/src/app/personal-admin/personal-admin.component.scss
0 → 100644
View file @
8d444326
apps/frontend/src/app/personal-admin/personal-admin.component.spec.ts
0 → 100644
View file @
8d444326
import
{
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
PersonalAdminComponent
}
from
'
./personal-admin.component
'
;
describe
(
'
PersonalAdminComponent
'
,
()
=>
{
let
component
:
PersonalAdminComponent
;
let
fixture
:
ComponentFixture
<
PersonalAdminComponent
>
;
beforeEach
(
async
()
=>
{
await
TestBed
.
configureTestingModule
({
declarations
:
[
PersonalAdminComponent
]
})
.
compileComponents
();
});
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
PersonalAdminComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
apps/frontend/src/app/personal-admin/personal-admin.component.ts
0 → 100644
View file @
8d444326
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
@
Component
({
selector
:
'
studio-lite-personal-admin
'
,
templateUrl
:
'
./personal-admin.component.html
'
,
styleUrls
:
[
'
./personal-admin.component.scss
'
]
})
export
class
PersonalAdminComponent
implements
OnInit
{
constructor
()
{
}
ngOnInit
():
void
{
}
}
apps/frontend/src/app/personal-admin/personal-admin.module.ts
0 → 100644
View file @
8d444326
import
{
NgModule
}
from
'
@angular/core
'
;
import
{
CommonModule
}
from
'
@angular/common
'
;
import
{
PersonalAdminComponent
}
from
'
./personal-admin.component
'
;
@
NgModule
({
declarations
:
[
PersonalAdminComponent
],
imports
:
[
CommonModule
]
})
export
class
PersonalAdminModule
{
}
apps/frontend/src/app/staff-list/backend.service.ts
0 → 100644
View file @
8d444326
import
{
catchError
}
from
'
rxjs/operators
'
;
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
Observable
}
from
'
rxjs
'
;
import
{
Injectable
,
Inject
}
from
'
@angular/core
'
;
import
{
StaffMemberInListDto
}
from
"
../../../../../libs/dto/src
"
;
@
Injectable
({
providedIn
:
'
root
'
})
export
class
BackendService
{
constructor
(
@
Inject
(
'
SERVER_URL
'
)
private
readonly
serverUrl
:
string
,
private
http
:
HttpClient
)
{}
getStaffList
():
Observable
<
StaffMemberInListDto
[]
>
{
return
this
.
http
.
get
<
StaffMemberInListDto
[]
>
(
`
${
this
.
serverUrl
}
staff`
)
.
pipe
(
catchError
(()
=>
[])
);
}
}
apps/frontend/src/app/staff-list/journal/journal.component.html
0 → 100644
View file @
8d444326
<p>
journal works!
</p>
apps/frontend/src/app/staff-list/journal/journal.component.scss
0 → 100644
View file @
8d444326
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment