Revision 49691
Added by Antonis Lempesis over 6 years ago
UserServiceImpl.java | ||
---|---|---|
4 | 4 |
import eu.dnetlib.gwt.server.service.SpringGwtRemoteServiceServlet; |
5 | 5 |
import eu.dnetlib.repo.manager.client.services.UserService; |
6 | 6 |
import eu.dnetlib.repo.manager.server.utils.EmailUtils; |
7 |
import eu.dnetlib.repo.manager.shared.Tuple; |
|
7 | 8 |
import eu.dnetlib.repo.manager.shared.UserAccessException; |
8 | 9 |
import eu.dnetlib.users.UserApi; |
9 | 10 |
import org.apache.log4j.Logger; |
... | ... | |
13 | 14 |
import javax.servlet.ServletConfig; |
14 | 15 |
import javax.servlet.ServletException; |
15 | 16 |
import java.util.ArrayList; |
17 |
import java.util.Arrays; |
|
16 | 18 |
import java.util.List; |
17 | 19 |
import java.util.regex.Pattern; |
18 | 20 |
|
... | ... | |
40 | 42 |
} |
41 | 43 |
|
42 | 44 |
@Override |
43 |
public UserProfile login(String email_username, String password) throws UserAccessException {
|
|
45 |
public Tuple<UserProfile, String> login(String email_username, String password) throws UserAccessException {
|
|
44 | 46 |
LOGGER.info("Checking credentials for user " + email_username); |
45 | 47 |
try { |
46 | 48 |
|
... | ... | |
64 | 66 |
throw new UserAccessException("login.InvalidPassword", UserAccessException.ErrorCode.INVALID_PASSWORD); |
65 | 67 |
} |
66 | 68 |
|
67 |
return this.userAPI.getUser(email); |
|
69 |
UserProfile userProfile = this.userAPI.getUser(email); |
|
70 |
String role = ""; |
|
68 | 71 |
|
72 |
String[] adminEmails = new String[] {"stefania.martziou@gmail.com" , "antleb@di.uoa.gr", "ant.lebesis@gmail.com", "natalia@di.uoa.gr", "pedroprincipe@sdum.uminho.pt", "dpierrakos@gmail.com", "jochen.schirrwagen@uni-bielefeld.de", "aenne.loehden@uni-bielefeld.de"}; |
|
73 |
if(Arrays.asList(adminEmails).contains(userProfile.getEmail())) |
|
74 |
role = "admin"; |
|
75 |
|
|
76 |
return new Tuple<>(userProfile, role); |
|
77 |
|
|
69 | 78 |
} catch (Exception e) { |
70 | 79 |
LOGGER.error("An error occurred while checking credentials for user " + email_username, e); |
71 | 80 |
emailUtils.reportException(e); |
... | ... | |
81 | 90 |
} |
82 | 91 |
|
83 | 92 |
@Override |
84 |
public UserProfile getUserByEmail(String email) throws UserAccessException {
|
|
93 |
public Tuple<UserProfile, String> getUserByEmail(String email) throws UserAccessException {
|
|
85 | 94 |
LOGGER.info("Getting user with email " + email); |
86 | 95 |
try { |
87 | 96 |
|
88 |
return this.userAPI.getUser(email); |
|
97 |
UserProfile userProfile = this.userAPI.getUser(email); |
|
98 |
String role = ""; |
|
89 | 99 |
|
100 |
String[] adminEmails = new String[] {"stefania.martziou@gmail.com" , "antleb@di.uoa.gr", "ant.lebesis@gmail.com", "natalia@di.uoa.gr", "pedroprincipe@sdum.uminho.pt", "dpierrakos@gmail.com", "jochen.schirrwagen@uni-bielefeld.de", "aenne.loehden@uni-bielefeld.de"}; |
|
101 |
if(Arrays.asList(adminEmails).contains(userProfile.getEmail())) |
|
102 |
role = "admin"; |
|
103 |
|
|
104 |
return new Tuple<>(userProfile, role); |
|
105 |
|
|
90 | 106 |
} catch (Exception e) { |
91 | 107 |
LOGGER.error("An error occurred while getting user with email " + email, e); |
92 | 108 |
emailUtils.reportException(e); |
Also available in: Unified diff
svn merge -r49522:HEAD https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-repository-manager-gui/trunk .