gpt4 book ai didi

java - GWTP 网守

转载 作者:行者123 更新时间:2023-12-01 08:53:46 26 4
gpt4 key购买 nike

我做了一些来自 GWTP 的例子

http://blog.arcbees.com/2015/10/27/gwtp-beginners-tutorial-toaster-launcher-part-2/#Gatekeeper

@DefaultGatekeeper
public class LoggedInGatekeeper implements Gatekeeper {
private CurrentUser currentUser;

@Inject
public LoggedInGatekeeper(CurrentUser currentUser) {
this.currentUser = currentUser;
}

@Override
public boolean canReveal() {
return currentUser.isLoggedIn();
}
}

如果用户登录,我们将授予访问权限。

是否可以找出想要访问的页面(NameToken)?以及是否给他权限,取决于权限

最佳答案

当然,只需将 PlaceManager 注入(inject)您的 LoggedInGatekeeper 并调用 getCurrentPlaceRequest然后将其与您的 NameToken 进行比较。大致如下:

@DefaultGatekeeper
public class LoggedInGatekeeper implements Gatekeeper {
private CurrentUser currentUser;
private PlaceManager placeManager;

@Inject
public LoggedInGatekeeper(CurrentUser currentUser, PlaceManager placeManager) {
this.currentUser = currentUser;
this.placeManager = placeManager;
}

@Override
public boolean canReveal() {
PlaceRequest request = placeManager.getCurrentPlaceRequest();
if (request.hasSameNameToken('someNameToken') {

return currentUser.isLoggedIn();
}
return true;
}
}

关于java - GWTP 网守,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42190424/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com