more concise and IMHO discoverable way to expose /me.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@20603 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2009-08-10 21:43:28 +00:00
1 parent 0a5762b6d1
commit 1a5c805584
2 files changed
+11 -24

No files matched your search

@@ -3127,6 +3127,16 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
return ManagementLink.all();
}
/**
* Exposes the current user to <tt>/me</tt> URL.
*/
public User getMe() {
User u = User.current();
if (u == null)
throw new AccessDeniedException("/me is not available when not logged in");
return u;
}
/**
* Gets the {@link Widget}s registered on this object.
*
+1 -24
View File
@@ -532,27 +532,4 @@ public class User extends AbstractModelObject implements AccessControlled, Savea
}
return null;
}
@Extension
public static class Me implements RootAction, StaplerProxy {
public String getDisplayName() {
return null;
}
public String getIconFileName() {
return null;
}
public String getUrlName() {
return "me";
}
public Object getTarget() {
if (User.current() == null) {
throw new AccessDeniedException("/me is not available when not logged in");
}
return User.current();
}
}}
}