Skip to content

Commit

Permalink
more demo users
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesbrandenburger committed Jan 16, 2024
1 parent 2d4dd69 commit 1b565a3
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<String> 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);
Expand All @@ -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
);
Expand All @@ -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);
Expand Down

0 comments on commit 1b565a3

Please sign in to comment.