Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 401949

Summary: UsersService.js has broken createUser()
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ClientAssignee: Mark Macdonald <mamacdon>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 3.0 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2013-02-27 15:10:44 EST
The createUser() method of UsersService.js does not correctly fulfill its service call contract. It returns a promise that never fulfills. The code looks like this:

> createUser : function(userName, password, email, onLoad, onError) {
> 	var ret = new Deferred();
> 	xhr("POST", "../users", { //$NON-NLS-1$ //$NON-NLS-0$
> 		data: form.encodeFormData({
> 			login : userName,
> 			password : password,
> 			email: email
> 		}),
> 		load : function(jsonData, xhrArgs) {
> 			ret.resolve(jsonData);
> 		},
> 		error : function(error, ioArgs) {
> 			ret.reject(error.response || error);
> 		}
> 	});
> 	return ret;
> },

Because it uses orion/xhr here, the "load" and "error" parameters are never called (they're leftover dojoisms). As a result, "ret" never resolves, and the promise is left hanging.

This makes it impossible to chain more aync operations to the result of a UserService call.
Comment 1 Mark Macdonald CLA 2013-02-27 15:36:47 EST
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=c41c5ee273943a2cf563ccc4cc952cef2580f8d3

This also fixes the problem with the user-list page not reloading after a user is created.
Comment 2 Mark Macdonald CLA 2013-02-27 17:46:52 EST
Needed to add this, to make sure that createUser() promises reject on error.

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=13c26546dc6e079ef431a2600d18080ccb987afc
Comment 3 Susan McCourt CLA 2013-02-28 12:29:17 EST
thanks, Mark.  I'm sure that one was my fault.  I thought I had opened a bug on this (see bug 395393 comment 12) but I can't find it.
Comment 4 Mark Macdonald CLA 2013-02-28 13:16:15 EST
(In reply to comment #3)
> thanks, Mark.  I'm sure that one was my fault.  I thought I had opened a bug
> on this (see bug 395393 comment 12) but I can't find it.

No, I think this happened prior to your big dojo-removal push. This files is part of a plugin, and the plugins were de-dojo'd before the UI was...