Skip to content
Snippets Groups Projects
Commit 8ae8c7a6 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Improve handling of admin account configuration

This fixes a potential NPE and should slightly improve performance.
parent e747a141
No related merge requests found
Pipeline #118 passed with stages
...@@ -132,7 +132,7 @@ public class UserService implements IUserService { ...@@ -132,7 +132,7 @@ public class UserService implements IUserService {
private int loginTryLimit; private int loginTryLimit;
@Value("${security.admin-accounts}") @Value("${security.admin-accounts}")
private String adminAccounts; private String[] adminAccounts;
private Pattern mailPattern; private Pattern mailPattern;
private BytesKeyGenerator keygen; private BytesKeyGenerator keygen;
...@@ -188,13 +188,12 @@ public class UserService implements IUserService { ...@@ -188,13 +188,12 @@ public class UserService implements IUserService {
} }
} }
String[] splittedNames = adminAccounts.split(",");
user.setAdmin(Arrays.asList(splittedNames).contains(user.getUsername()));
if (user == null || user.getUsername().equals("anonymous")) { if (user == null || user.getUsername().equals("anonymous")) {
throw new UnauthorizedException(); throw new UnauthorizedException();
} }
user.setAdmin(Arrays.asList(adminAccounts).contains(user.getUsername()));
return user; return user;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment