Revision 49592
Added by Stefania Martziou over 6 years ago
RepositoryManager.java | ||
---|---|---|
17 | 17 |
import eu.dnetlib.domain.functionality.UserProfile; |
18 | 18 |
import eu.dnetlib.repo.manager.client.services.UserService; |
19 | 19 |
import eu.dnetlib.repo.manager.client.services.UserServiceAsync; |
20 |
import eu.dnetlib.repo.manager.shared.Tuple; |
|
20 | 21 |
import eu.dnetlib.repo.manager.shared.UserAccessException; |
21 | 22 |
|
22 | 23 |
import java.util.logging.Level; |
... | ... | |
28 | 29 |
public class RepositoryManager implements EntryPoint { |
29 | 30 |
|
30 | 31 |
public static UserProfile currentUser = null; |
32 |
public static String currentUserRole = null; |
|
31 | 33 |
|
32 | 34 |
public static String publicCaptchaKey = ""; |
33 | 35 |
|
... | ... | |
123 | 125 |
|
124 | 126 |
} else { |
125 | 127 |
|
126 |
userService.getUserByEmail(Crypto.decrypt(encryptedEmail), new AsyncCallback<UserProfile>() {
|
|
128 |
userService.getUserByEmail(Crypto.decrypt(encryptedEmail), new AsyncCallback<Tuple<UserProfile, String>>() {
|
|
127 | 129 |
|
128 | 130 |
@Override |
129 |
public void onFailure(Throwable t) { |
|
131 |
public void onFailure(Throwable caught) {
|
|
130 | 132 |
|
131 | 133 |
Cookies.removeCookie("currentUser"); |
132 | 134 |
|
... | ... | |
136 | 138 |
} |
137 | 139 |
|
138 | 140 |
@Override |
139 |
public void onSuccess(UserProfile userProfile) {
|
|
141 |
public void onSuccess(Tuple<UserProfile, String> result) {
|
|
140 | 142 |
|
141 |
RepositoryManager.currentUser = userProfile; |
|
143 |
RepositoryManager.currentUser = result.getFirst(); |
|
144 |
RepositoryManager.currentUserRole = result.getSecond(); |
|
145 |
|
|
142 | 146 |
if (RepositoryManager.currentUser != null) |
143 | 147 |
Document.get().getElementById("currentUser").setInnerText(RepositoryManager.currentUser.getFirstname() |
144 | 148 |
+ " " + RepositoryManager.currentUser.getLastname()); |
145 | 149 |
|
146 | 150 |
//TODO use role instead of email |
147 |
if(RepositoryManager.currentUser.getEmail().equals("stefania.martziou@gmail.com")) { |
|
148 |
Document.get().getElementById("helpAdmin_li").getStyle().setDisplay(Style.Display.BLOCK); |
|
151 |
if(RepositoryManager.currentUserRole.equals("admin")) { |
|
152 |
Document.get().getElementById("admin1").getStyle().setDisplay(Style.Display.BLOCK); |
|
153 |
Document.get().getElementById("admin2").getStyle().setDisplay(Style.Display.BLOCK); |
|
149 | 154 |
} |
150 | 155 |
|
151 | 156 |
String finalHistoryToken = getFinalHistoryToken(hashValue); |
... | ... | |
167 | 172 |
|
168 | 173 |
Cookies.removeCookie("currentUser"); |
169 | 174 |
RepositoryManager.currentUser = null; |
175 |
RepositoryManager.currentUserRole = null; |
|
170 | 176 |
|
171 | 177 |
if(RepositoryManager.currentToken.equals("landing")) |
172 | 178 |
NavigationManager.getInstance().navigate("landing"); |
... | ... | |
186 | 192 |
historyToken = "landing"; |
187 | 193 |
} |
188 | 194 |
|
195 |
} else if(!RepositoryManager.currentUserRole.equals("admin")) { |
|
196 |
if(historyToken.equals("admin/helpTexts") || historyToken.equals("admin/metrics")) { |
|
197 |
historyToken = "dashboard"; |
|
198 |
} |
|
189 | 199 |
} |
190 | 200 |
|
191 | 201 |
return historyToken; |
Also available in: Unified diff
The Admin menu can now only be viewed and accessed by a list of email addresses