diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index 4e707ccaaa..3008995bf0 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -3127,6 +3127,16 @@ public final class Hudson extends Node implements ItemGroup, Stapl return ManagementLink.all(); } + /** + * Exposes the current user to /me 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. * diff --git a/core/src/main/java/hudson/model/User.java b/core/src/main/java/hudson/model/User.java index 0b13703ccc..ee3029a441 100644 --- a/core/src/main/java/hudson/model/User.java +++ b/core/src/main/java/hudson/model/User.java @@ -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(); - } - - }} +}