Revision 1e1441bf

b/src/gr/grnet/pithos/web/client/AddUserDialog.java
48 48
import com.google.gwt.event.dom.client.KeyDownEvent;
49 49
import com.google.gwt.http.client.Response;
50 50
import com.google.gwt.http.client.URL;
51
import com.google.gwt.regexp.shared.RegExp;
51 52
import com.google.gwt.user.client.Event.NativePreviewEvent;
52 53
import com.google.gwt.user.client.ui.Anchor;
53 54
import com.google.gwt.user.client.ui.Button;
......
179 180
		String name = userName.getText().trim();
180 181
		if (name.length() == 0)
181 182
			return;
183
		RegExp emailValidator = RegExp.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$", "i");
184
		if (!emailValidator.test(name)) {
185
			app.displayWarning("Username must be a valid email address");
186
			return;
187
		}
188
			
182 189
    	group.addMember(name);
183 190
    	String path = "?update=";
184 191
    	PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUsername(), path) {
b/src/gr/grnet/pithos/web/client/PermissionsAddDialog.java
42 42
import com.google.gwt.event.dom.client.ClickEvent;
43 43
import com.google.gwt.event.dom.client.ClickHandler;
44 44
import com.google.gwt.event.dom.client.KeyCodes;
45
import com.google.gwt.regexp.shared.RegExp;
45 46
import com.google.gwt.user.client.Event.NativePreviewEvent;
46 47
import com.google.gwt.user.client.ui.Anchor;
47 48
import com.google.gwt.user.client.ui.Button;
......
139 140
	protected void addPermission() {
140 141
        String selected = null;
141 142
		if (userAdd) {
142
			selected = userBox.getText();
143
			selected = userBox.getText().trim();
144
			RegExp emailValidator = RegExp.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$", "i");
145
			if (!emailValidator.test(selected)) {
146
				app.displayWarning("Username must be a valid email address");
147
				return;
148
			}
143 149
		} else if (groupBox.getSelectedIndex() > -1) {
144 150
			String groupName = groupBox.getValue(groupBox.getSelectedIndex());
145 151
			selected = app.getUsername() + ":" + groupName;
......
148 154
            return;
149 155
        }
150 156
        if (selected == null || selected.length() == 0 || selected.equals(app.getUsername() + ":")) {
151
        	app.displayError("You have to select o username or group");
157
        	app.displayWarning("You have to select a username or group");
152 158
        	return;
153 159
        }
160

  
154 161
		boolean readValue = read.getValue();
155 162
		boolean writeValue = write.getValue();
156 163

  

Also available in: Unified diff