| | |
| | | import org.apache.wicket.model.util.CollectionModel;
|
| | | import org.apache.wicket.model.util.ListModel;
|
| | |
|
| | | import com.gitblit.Constants.RegistrantType;
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.GitBlitException;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.Constants.PermissionType;
|
| | | import com.gitblit.Constants.RegistrantType;
|
| | | import com.gitblit.models.RegistrantAccessPermission;
|
| | | import com.gitblit.models.TeamModel;
|
| | | import com.gitblit.models.UserModel;
|
| | |
| | | public EditUserPage() {
|
| | | // create constructor
|
| | | super();
|
| | | if (!GitBlit.self().supportsCredentialChanges()) {
|
| | | if (!GitBlit.self().supportsAddUser()) {
|
| | | error(MessageFormat.format(getString("gb.userServiceDoesNotPermitAddUser"),
|
| | | GitBlit.getString(Keys.realm.userService, "users.conf")), true);
|
| | | GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);
|
| | | }
|
| | | isCreate = true;
|
| | | setupPage(new UserModel(""));
|
| | |
| | | setupPage(model);
|
| | | setStatelessHint(false);
|
| | | setOutputMarkupId(true);
|
| | | }
|
| | | |
| | | @Override
|
| | | protected boolean requiresPageMap() {
|
| | | return true;
|
| | | }
|
| | |
|
| | | protected void setupPage(final UserModel userModel) {
|
| | |
| | | Collections.sort(userTeams);
|
| | |
|
| | | final String oldName = userModel.username;
|
| | | final List<RegistrantAccessPermission> permissions = userModel.getRepositoryPermissions();
|
| | | for (RegistrantAccessPermission permission : permissions) {
|
| | | if (permission.isEditable && PermissionType.EXPLICIT.equals(permission.permissionType)) {
|
| | | // Ensure this is NOT an owner permission - which is non-editable
|
| | | // We don't know this from within the usermodel, ownership is a
|
| | | // property of a repository.
|
| | | boolean isOwner = GitBlit.self().getRepositoryModel(permission.registrant).isOwner(oldName);
|
| | | if (isOwner) {
|
| | | permission.permissionType = PermissionType.OWNER;
|
| | | permission.isEditable = false;
|
| | | }
|
| | | }
|
| | | }
|
| | | final List<RegistrantAccessPermission> permissions = GitBlit.self().getUserAccessPermissions(userModel);
|
| | |
|
| | | final Palette<String> teams = new Palette<String>("teams", new ListModel<String>(
|
| | | new ArrayList<String>(userTeams)), new CollectionModel<String>(GitBlit.self()
|
| | |
| | | }
|
| | | boolean rename = !StringUtils.isEmpty(oldName)
|
| | | && !oldName.equalsIgnoreCase(username);
|
| | | if (GitBlit.self().supportsCredentialChanges()) {
|
| | | if (GitBlit.self().supportsCredentialChanges(userModel)) {
|
| | | if (!userModel.password.equals(confirmPassword.getObject())) {
|
| | | error(getString("gb.passwordsDoNotMatch"));
|
| | | return;
|
| | |
| | | form.add(new SimpleAttributeModifier("autocomplete", "off"));
|
| | |
|
| | | // not all user services support manipulating username and password
|
| | | boolean editCredentials = GitBlit.self().supportsCredentialChanges();
|
| | | boolean editCredentials = GitBlit.self().supportsCredentialChanges(userModel);
|
| | |
|
| | | // not all user services support manipulating display name
|
| | | boolean editDisplayName = GitBlit.self().supportsDisplayNameChanges();
|
| | | boolean editDisplayName = GitBlit.self().supportsDisplayNameChanges(userModel);
|
| | |
|
| | | // not all user services support manipulating email address
|
| | | boolean editEmailAddress = GitBlit.self().supportsEmailAddressChanges();
|
| | | boolean editEmailAddress = GitBlit.self().supportsEmailAddressChanges(userModel);
|
| | |
|
| | | // not all user services support manipulating team memberships
|
| | | boolean editTeams = GitBlit.self().supportsTeamMembershipChanges();
|
| | | boolean editTeams = GitBlit.self().supportsTeamMembershipChanges(userModel);
|
| | |
|
| | | // field names reflective match UserModel fields
|
| | | form.add(new TextField<String>("username").setEnabled(editCredentials));
|
| | |
| | | form.add(new TextField<String>("displayName").setEnabled(editDisplayName));
|
| | | form.add(new TextField<String>("emailAddress").setEnabled(editEmailAddress));
|
| | | form.add(new CheckBox("canAdmin"));
|
| | | form.add(new CheckBox("canFork"));
|
| | | form.add(new CheckBox("canFork").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));
|
| | | form.add(new CheckBox("canCreate"));
|
| | | form.add(new CheckBox("excludeFromFederation"));
|
| | | form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY, repos, permissions, getAccessPermissions()));
|
| | | form.add(teams.setEnabled(editTeams));
|
| | |
|
| | | form.add(new TextField<String>("organizationalUnit").setEnabled(editDisplayName));
|
| | | form.add(new TextField<String>("organization").setEnabled(editDisplayName));
|
| | | form.add(new TextField<String>("locality").setEnabled(editDisplayName));
|
| | | form.add(new TextField<String>("stateProvince").setEnabled(editDisplayName));
|
| | | form.add(new TextField<String>("countryCode").setEnabled(editDisplayName));
|
| | | form.add(new Button("save"));
|
| | | Button cancel = new Button("cancel") {
|
| | | private static final long serialVersionUID = 1L;
|