From 80c629594f5dc860c5781e599b0077f74756703b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kr=C3=B6ll?= Date: Tue, 19 Oct 2021 13:35:12 +0200 Subject: [PATCH] rename refresh_token & fix ticket permissions (#83) * change refresh-token generation * return error * refresh_token -> refresh-token * refresh_token -> refreshToken * Dialog fixes. * Ticket assignment. * wider assignment button * changed ticket permissions --- .../controller/ClassroomApiController.kt | 13 +++++--- .../create-conference-dialog.component.html | 16 ++++----- .../create-conference-dialog.component.scss | 24 +++++++++++++- .../create-edit-ticket.component.html | 25 +++++++------- ...conference-to-ticket-dialog.component.html | 4 +-- .../ticket-assign.component.html | 33 +++++++++++-------- .../ticket-assign.component.scss | 10 +++--- .../ticket-user-display.component.scss | 1 + .../ticket-list/ticket/ticket.component.html | 9 +++-- .../ticket-list/ticket/ticket.component.scss | 7 ++++ .../ticket-list/ticket/ticket.component.ts | 9 +++++ .../menu-bar/menu-bar.component.html | 4 +-- .../menu-bar/menu-bar.component.scss | 9 +++-- web-gui/src/app/service/auth.service.ts | 8 ++--- web-gui/src/app/service/classroom.service.ts | 8 ----- 15 files changed, 109 insertions(+), 71 deletions(-) diff --git a/src/main/kotlin/de/thm/mni/ii/classroom/controller/ClassroomApiController.kt b/src/main/kotlin/de/thm/mni/ii/classroom/controller/ClassroomApiController.kt index b47d099..4e7c6ea 100644 --- a/src/main/kotlin/de/thm/mni/ii/classroom/controller/ClassroomApiController.kt +++ b/src/main/kotlin/de/thm/mni/ii/classroom/controller/ClassroomApiController.kt @@ -48,7 +48,7 @@ class ClassroomApiController( }.map { val refreshToken = generateRefreshToken(auth.principal) // Set refresh_token header - val refreshTokenSet = setHeader("refresh_token", refreshToken, originalExchange) + val refreshTokenSet = setHeader("refreshToken", refreshToken, originalExchange) // Set Authorization header setHeader(HttpHeaders.AUTHORIZATION, "Bearer ${auth.credentials}", refreshTokenSet).response }.doOnNext { @@ -61,7 +61,7 @@ class ClassroomApiController( fun refreshToken( auth: ClassroomAuthentication, originalExchange: ServerWebExchange, - @RequestHeader("refresh_token") refreshToken: String + @RequestHeader("refreshToken") refreshToken: String ): Mono { return classroomTokenRepository .findRefreshToken(refreshToken) @@ -71,18 +71,23 @@ class ClassroomApiController( }.switchIfEmpty(Mono.error(UnauthorizedException("Owner of refresh token does not match requester!"))) .map { user -> val newRefreshToken = generateRefreshToken(user) - Pair(user, setHeader("refresh_token", newRefreshToken, originalExchange)) + Pair(user, setHeader("refreshToken", newRefreshToken, originalExchange)) }.flatMap { (user, exchange) -> Mono.zip(jwtService.createToken(user), Mono.just(exchange)) }.map { (jwt, exchange) -> setHeader(HttpHeaders.AUTHORIZATION, "Bearer $jwt", exchange).response }.doOnNext { logger.info("${auth.principal} refreshed his JWT!") + }.onErrorResume { error -> + logger.error(error.message) + originalExchange.response.statusCode = HttpStatus.BAD_REQUEST + originalExchange.response.bufferFactory().wrap(error.message!!.encodeToByteArray()) + Mono.just(originalExchange.response) } } private fun generateRefreshToken(userCredentials: UserCredentials): String { - val newRefreshToken = RandomStringUtils.randomAscii(30) + val newRefreshToken = RandomStringUtils.randomAlphanumeric(30) classroomTokenRepository.insertRefreshToken(newRefreshToken, userCredentials) return newRefreshToken } diff --git a/web-gui/src/app/dialogs/create-conference-dialog/create-conference-dialog.component.html b/web-gui/src/app/dialogs/create-conference-dialog/create-conference-dialog.component.html index 53c15e5..aeaa5cb 100644 --- a/web-gui/src/app/dialogs/create-conference-dialog/create-conference-dialog.component.html +++ b/web-gui/src/app/dialogs/create-conference-dialog/create-conference-dialog.component.html @@ -1,9 +1,9 @@ -

Neue Konferenz erstellen

-
+
+
Neue Konferenz erstellen
-
+ - Konferenz Name + Konferenzname
@@ -12,8 +12,8 @@

Neue Konferenz erstellen

- - - - + + + +
diff --git a/web-gui/src/app/dialogs/create-conference-dialog/create-conference-dialog.component.scss b/web-gui/src/app/dialogs/create-conference-dialog/create-conference-dialog.component.scss index fe08f57..154d1c1 100644 --- a/web-gui/src/app/dialogs/create-conference-dialog/create-conference-dialog.component.scss +++ b/web-gui/src/app/dialogs/create-conference-dialog/create-conference-dialog.component.scss @@ -2,6 +2,28 @@ button { margin: 3px; } +.container { + width: 20rem; + +} + +form { + display: flex; + flex-direction: column; +} + mat-dialog-content { - display: unset; + width: 20rem; + display: flex; + flex-direction: column; + overflow: hidden; +} + +.checkbox-form { + margin-bottom: 10px; +} + +mat-action-row { + width: unset; + margin-top: 10px; } diff --git a/web-gui/src/app/dialogs/create-edit-ticket/create-edit-ticket.component.html b/web-gui/src/app/dialogs/create-edit-ticket/create-edit-ticket.component.html index 478b0ba..62196e1 100644 --- a/web-gui/src/app/dialogs/create-edit-ticket/create-edit-ticket.component.html +++ b/web-gui/src/app/dialogs/create-edit-ticket/create-edit-ticket.component.html @@ -1,12 +1,13 @@ -

{{title}}

- - - - Beschreibung - - - - - - - +
+
{{title}}
+ + + Beschreibung + + + + + + + +
diff --git a/web-gui/src/app/dialogs/link-conference-to-ticket-dialog/link-conference-to-ticket-dialog.component.html b/web-gui/src/app/dialogs/link-conference-to-ticket-dialog/link-conference-to-ticket-dialog.component.html index a445439..bacf162 100644 --- a/web-gui/src/app/dialogs/link-conference-to-ticket-dialog/link-conference-to-ticket-dialog.component.html +++ b/web-gui/src/app/dialogs/link-conference-to-ticket-dialog/link-conference-to-ticket-dialog.component.html @@ -9,7 +9,7 @@ - - + +
diff --git a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-assign/ticket-assign.component.html b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-assign/ticket-assign.component.html index b398416..12fb448 100644 --- a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-assign/ticket-assign.component.html +++ b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-assign/ticket-assign.component.html @@ -1,23 +1,28 @@ - - - - - - - - - - - +
+ + + + + + + + + + + +
- add_circle_outline  + add_circle_outline zuweisen
- person_off  - n/a + person_off +
+ zugewiesen + Niemand +
diff --git a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-assign/ticket-assign.component.scss b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-assign/ticket-assign.component.scss index 7f71295..4eba8c4 100644 --- a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-assign/ticket-assign.component.scss +++ b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-assign/ticket-assign.component.scss @@ -2,12 +2,7 @@ display: flex; flex-flow: row nowrap; align-items: center; - min-width: 132px; - height: 38px; -} - -.user-select { - min-width: 132px; + width: 210px; height: 38px; } @@ -62,3 +57,6 @@ mat-select-trigger { display: none; } +.container { + width: 100%; +} diff --git a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-user-display/ticket-user-display.component.scss b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-user-display/ticket-user-display.component.scss index bcd46e1..9c71898 100644 --- a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-user-display/ticket-user-display.component.scss +++ b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-user-display/ticket-user-display.component.scss @@ -3,6 +3,7 @@ flex-flow: row nowrap; align-items: center; min-width: 132px; + max-width: 200px; height: 38px; .user-avatar { height: 32px; diff --git a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.html b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.html index 8d80d88..ffd288d 100644 --- a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.html +++ b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.html @@ -9,18 +9,17 @@

{{this.getTicketTime(ticket)}}

-
{{ticket.description}}
-
+
-
+
- edit - delete + edit + delete
diff --git a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.scss b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.scss index 83ac3ed..1450d8f 100644 --- a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.scss +++ b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.scss @@ -22,6 +22,13 @@ mat-card-content { font-size: 14px; color: #6D6D6D; } + .ticket-users { + display: flex; + flex-flow: row nowrap; + justify-content: space-between; + align-items: center; + padding-left: 5px; + } .ticket-meta { alignment: left; width: 78px; diff --git a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.ts b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.ts index 5dcabc1..71c8555 100644 --- a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.ts +++ b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket.component.ts @@ -43,6 +43,15 @@ export class TicketComponent implements OnInit { return "invite" } + public mayDeleteTicket(): boolean { + return this.classroomService.isSelf(this.ticket?.creator!!) || + this.classroomService.isCurrentUserPrivileged() + } + + public mayEditTicket(): boolean { + return this.classroomService.isSelf(this.ticket?.creator!!) + } + editTicket() { this.classroomService.createOrEditTicket(this.ticket) } diff --git a/web-gui/src/app/page-components/menu-bar/menu-bar.component.html b/web-gui/src/app/page-components/menu-bar/menu-bar.component.html index cec4181..74f6ec8 100644 --- a/web-gui/src/app/page-components/menu-bar/menu-bar.component.html +++ b/web-gui/src/app/page-components/menu-bar/menu-bar.component.html @@ -3,8 +3,8 @@ supervised_user_circle {{parseCourseRole(currentUser?.userRole)}}
-