diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/models/user/User.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/models/user/User.java index 20e1663..fde91f9 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/models/user/User.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/models/user/User.java @@ -20,7 +20,7 @@ public class User { private String username; private String email; private String passwordHash; - private final Role role; + private Role role; private Settings settings; private Inbox inbox; @@ -200,4 +200,12 @@ public void setInbox(Inbox inbox) { } this.inbox = inbox; } + + public void setRole(Role role) { + if (role == null) { + throw new IllegalArgumentException("Inbox cannot be null"); + } + this.role = role; + } } + diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/service/AuthenticationService.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/service/AuthenticationService.java index cd9cbc2..032d138 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/service/AuthenticationService.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/service/AuthenticationService.java @@ -55,6 +55,9 @@ public boolean login(String email, String password){ if (user != null){ currentUser = user; isCharityUser = userDataReader.getUserCharityUser(currentUser.getId().toString()); + if (isCharityUser != null){ + currentUser.setRole(Role.CHARITY_USER); + } System.out.println("User gotten"); return true; }