Skip to content

Commit

Permalink
Guest user not kicked off after refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
softwaremagico committed Jun 20, 2024
1 parent cdae4d6 commit a9cbd20
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![GitHub last commit](https://img.shields.io/github/last-commit/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![CircleCI](https://circleci.com/gh/softwaremagico/KendoTournamentManager.svg?style=shield)](https://circleci.com/gh/softwaremagico/KendoTournamentManager)
[![Time](https://img.shields.io/badge/development-636.5h-blueviolet.svg)]()
[![Time](https://img.shields.io/badge/development-637.5h-blueviolet.svg)]()

[![Powered by](https://img.shields.io/badge/powered%20by%20java-orange.svg?logo=OpenJDK&logoColor=white)]()
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=kendo-tournament-backend&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=kendo-tournament-backend)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<DuelDTO> getUntiesFromTournament(@Parameter(description = "Id of the
}


@PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN')")
@PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN', 'ROLE_PARTICIPANT')")
@Operation(summary = "Gets all untie duel where one participant is involved.", security = @SecurityRequirement(name = "bearerAuth"))
@GetMapping(value = "/participant/{participantId}/unties", produces = MediaType.APPLICATION_JSON_VALUE)
public List<DuelDTO> getUntiesFromParticipant(@Parameter(description = "Id of the participant.", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public List<FightDTO> createNext(@Parameter(description = "Id of an existing tou
}


@PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN')")
@PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN', 'ROLE_PARTICIPANT')")
@Operation(summary = "Gets all fights from competitor.", security = @SecurityRequirement(name = "bearerAuth"))
@GetMapping(value = "/competitor/{competitorId}", produces = MediaType.APPLICATION_JSON_VALUE)
public List<FightDTO> getByCompetitor(@Parameter(description = "Id of the competitor.", required = true)
Expand Down
18 changes: 0 additions & 18 deletions frontend/src/app/interceptors/logged-in.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class LoggedInService {
}

userLoginPageDependingOnRoles(context: string, params: string): boolean {
debugger
if (this.loginService.getJwtValue()) {
//Participant users must redirect to their statistcs.
if (localStorage.getItem('account') == 'participant'
Expand All @@ -45,23 +44,6 @@ export class LoggedInService {
} else if (localStorage.getItem('account') == 'guest' && !context.startsWith('/tournaments/fights')) {
this.router.navigate(['/tournaments/fights']);
}
// this.loginService.getUserRoles().subscribe((_roles: String[]): void => {
// if (_roles.includes("viewer") || _roles.includes("editor") || _roles.includes("admin")) {
// // Do nothing and navigate as usual.
// } else if (_roles.includes("guest")) {
// //Gets last tournament and redirects to fight list.
// this.tournamentService.getLastUnlockedTournament().subscribe((_tournament: Tournament): void => {
// //Path '/tournaments/fights' and '/fights/championship' does not call LoggedInService to avoid redirect loops.
// if (_tournament) {
// this.router.navigate(['/tournaments/fights'], {state: {tournamentId: _tournament.id}});
// } else {
// this.router.navigate(['/login']);
// }
// });
// } else if (_roles.includes("participant")) {
// this.router.navigate(['/participants/statistics']);
// }
// });
return true;
}
return this.whiteListedPages.includes(context);
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/services/login.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class LoginService {
next: (authenticatedUser: AuthenticatedUser): void => {
this.setAuthenticatedUser(authenticatedUser, callback);
localStorage.setItem('account', 'guest');
debugger
localStorage.setItem('tournamentId', tournamentId + "");
},
error: (): void => {
this.router.navigate(["/"]);
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/app/views/fight-list/fight-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export class FightListComponent extends RbacBasedComponent implements OnInit, On
} else {
//Gets tournament from URL parameter (from QR codes).
this.tournamentId = Number(this.activatedRoute.snapshot.queryParamMap.get('tournamentId'));
if (!this.tournamentId) {
this.tournamentId = Number(localStorage.getItem('tournamentId'));
debugger
}
if (!this.tournamentId || isNaN(this.tournamentId)) {
this.goBackToTournament();
}
Expand Down

0 comments on commit a9cbd20

Please sign in to comment.