开发者

getAuthDomain() in GWT is always returning gmail.com

I'm writing an application with Google Web Toolkit and am trying to figure out the Google Apps domain of the user currently logged in.

public LoginInfo login(String requestUri) {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    LoginInfo loginInfo = new LoginInfo();

    if (user != null) {
        loginInfo.setLoggedIn(true);
        loginInfo.setEmailAddress(user.getEmail());
        loginInfo.setNickname(user.getNickname());
        loginInfo.setAuthDomain(user.getAuthDomain());
        loginInfo.setLogoutUrl(userService.createLogoutURL(requestUri));
        loginInfo.setIsAdmin(userService.isUserAdmin());
    } else {
        loginInfo.setLoggedIn(false);
        loginInfo.setLoginUrl(userService.createLoginURL(requestUri));
    }
    return loginInfo;
}

But user.getAuthDomain() is always returning "gmail.com".

which should be correct for non-google-apps-users. But it also returns gmail.com when I log in with my google apps account.

开发者_C百科Any ideas why? Or is there an other method to get the users current domain?


I would use GWT.getHostPageBaseUrl() to access the host page's base URL, and parse the domain name from that.


This will solve your thing:

`String domain=ApiProxy.getCurrentEnvironment().getAttributes().get("com.google.appengine.api.users.UserService.user_organization").toString();`
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜