提交 e04fb0f0 编写于 作者: K kohsuke

adding sign-up support.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6323 71c3de6d-444a-0410-be80-ed276b4c234a
上级 b3c4e013
......@@ -1847,6 +1847,13 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
req.getView(this,"_script.jelly").forward(req,rsp);
}
/**
* Sign up for the user account.
*/
public void doSignup( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
req.getView(getSecurityRealm(),"signup.jelly").forward(req,rsp);
}
/**
* Changes the icon size by changing the cookie
*/
......
......@@ -3,10 +3,12 @@ package hudson.security;
import hudson.ExtensionPoint;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.util.DescriptorList;
import org.acegisecurity.Authentication;
import org.acegisecurity.AuthenticationManager;
import org.springframework.context.ApplicationContext;
import org.kohsuke.stapler.Stapler;
import java.util.Map;
......@@ -16,6 +18,11 @@ import java.util.Map;
* <p>
* New implementations should be registered to {@link #LIST}.
*
* <p>
* If additional views/URLs need to be exposed,
* an active {@link SecurityRealm} is bound to <tt>CONTEXT_ROOT/securityRealm/</tt>
* through {@link Hudson#getSecurityRealm()}.
*
* @author Kohsuke Kawaguchi
* @sicne 1.160
*/
......@@ -35,12 +42,30 @@ public abstract class SecurityRealm implements Describable<SecurityRealm>, Exten
/**
* Returns the URL to submit a form for the authentication.
* Normally there's no need to override this.
* There's no need to override this, except for {@link LegacySecurityRealm}.
*/
public String getLoginUrl() {
return "j_acegi_security_check";
}
/**
* Returns true if this {@link SecurityRealm} allows online sign-up.
* This creates a hyperlink that redirects users to <tt>CONTEXT_ROOT/signUp</tt>,
* which will be served by the <tt>signup.jelly</tt> view of this class.
*
* <p>
* If the implementation needs to redirect the user to a different URL
* for signing up, use the following jelly script as <tt>signup.jelly</tt>
*
* <pre><xmp>
* <st:redirect url="http://www.sun.com/" xmlns:st="jelly:stapler"/>
* </xmp></pre>
*/
public final boolean allowsSignup() {
Class clz = getClass();
return clz.getClassLoader().getResource(clz.getName().replace('.','/')+"/signup.jelly")!=null;
}
/**
* Picks up the instance of the given type from the spring context.
* If there are multiple beans of the same type or if there are none,
......
......@@ -11,7 +11,7 @@
<td><input type="text" name="j_username" id="j_username" /></td>
</tr>
<tr>
<td>Password</td>
<td>Password:</td>
<td><input type="password" name="j_password" /></td>
</tr>
</table>
......@@ -20,6 +20,12 @@
$('j_username').focus();
</script>
</form>
<j:if test="${it.securityRealm.allowsSignup()}">
<div style="margin-top:2em">
<a href="signup">Create an account</a> if you are not a member yet.
</div>
</j:if>
</div>
</l:main-panel>
</l:layout>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册