I want to write a Jira plugin that force people to use a certain username pattern when they register their accounts in Jira.
This is happening inside the form is displayed at `/secure/Signup!default.jspa` and is based on `$JIRA_INSTALL/atlassian-jira/views/signup.jsp` view.
Still, I have no idea what to put inside the plugin in order to make it fail, and also I do not want to go the easy way and implement this in JavaScript on the client, not because of security, just because I want a solution that does not brake when you upgrade Jira.
Update: I found that DefaultUserService.java - still I'm not sure how to implement this in a plugin and preferably writing a minimal amount of code.
Probably what I need is to throw a CreateExeption from inside the plugin, but what to implement inside the plugin to throw this?
Because I don't want to loose my customization each time I'm doing a Jira update, I ended up writing a jQuery check. I know, it is not safe but it is better than loosing changes on updates.
You have to overwrite the Signup WebAction as described in this tutorial: http://www.j-tricks.com/1/post/2010/10/extending-jira-actions.html
In this case it should be the following definition in your atlassian-plugin.xml:
<webwork1 key="new-signup" name="New Signup" class="java.lang.Object">
<actions>
<action name="com.foo.bar.NewSignup" alias="Signup">
<view name="success">/views/signup-success.jsp</view>
<view name="limitexceeded">/views/signup-limitexceeded.jsp</view>
<view name="alreadyloggedin">/views/signup-alreadyloggedin.jsp</view>
<view name="error">/views/signup.jsp</view>
<view name="input">/views/signup.jsp</view>
<view name="modebreach">/views/modebreach.jsp</view>
<view name="systemerror">/views/signup-systemerror.jsp</view>
</action>
</actions>
</webwork1>
Then you have to extend com.atlassian.jira.web.action.user.Signup and validate the username:
@Override
protected void doValidation() {
if (getUsername().matches("mypattern")){
addError("username", getText("mytext"));
}
super.doValidation();
}
Then the user sees a red error message at the username field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.