From 1b565a34756d7a559133064073428bf55612c77a Mon Sep 17 00:00:00 2001 From: Johannes Brandenburger <79154528+johannesbrandenburger@users.noreply.github.com> Date: Tue, 16 Jan 2024 13:17:49 +0100 Subject: [PATCH] more demo users --- .../mobilelearning/services/auth/UserService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/de/htwg_konstanz/mobilelearning/services/auth/UserService.java b/backend/src/main/java/de/htwg_konstanz/mobilelearning/services/auth/UserService.java index 175c99d1..497809a6 100644 --- a/backend/src/main/java/de/htwg_konstanz/mobilelearning/services/auth/UserService.java +++ b/backend/src/main/java/de/htwg_konstanz/mobilelearning/services/auth/UserService.java @@ -1,5 +1,8 @@ package de.htwg_konstanz.mobilelearning.services.auth; +import java.util.Arrays; +import java.util.List; + import org.jboss.resteasy.reactive.RestHeader; import de.htwg_konstanz.mobilelearning.models.Course; @@ -48,7 +51,8 @@ public Response login(@RestHeader("Authorization") String authorization) throws User userFromLdap = null; // TEMP: bypass ldap (student, prof, admin as username) - if (username.equals("Student") || username.equals("Prof") || username.equals("Admin")) { + List demoUsernames = Arrays.asList("Student", "Prof", "Admin", "Brande", "Tobi", "Marvin", "Leon", "Fabi", "Schimkat", "Landwehr" ); + if (demoUsernames.contains(username)) { // check if user exists in db User existingUser = userRepository.findByUsername(username); @@ -64,7 +68,7 @@ public Response login(@RestHeader("Authorization") String authorization) throws User newUser = new User( username + "@htwg-konstanz.de", - "Test" + username, + "Testuser: " + username, username, password ); @@ -75,6 +79,8 @@ public Response login(@RestHeader("Authorization") String authorization) throws newUser.addRole(UserRole.PROF); } else if (username.equals("Admin")) { newUser.addRole(UserRole.ADMIN); + } else { + newUser.addRole(UserRole.STUDENT); } userRepository.persist(newUser);