onSubmit: function() { // Gather the login data var loginData = { userID: this.getChild('user').value, pWord: Ti.Utils.md5HexDigest(this.getChild('password').value) // MD5 hash the user's password }; // Send login request to the server Ti.API.log('Attempting to login as {'+loginData.userID+', '+loginData.pWord+'}'); AD.ServiceJSON.post({ params: loginData, url: '/service/site/login/authenticate', success: this.proxy(function(data) { Ti.API.log('Login succeeded!'); this.close(); // Call the onLogin callback if it was provided to the "open" call if ($.isFunction(this.onLogin)) { this.onLogin(); } }), failure: function(data) { Ti.API.log('Login failed!'); } }); },
findOne: function(opt){ return AD.ServiceJSON.post({ url: opt.url, params: opt.params, success: function (data) { opt.success(ServiceModel.returnFirst(data) ); }, failure: opt.failure, }); },
destroy: function (opt) { return AD.ServiceJSON.post({ url: opt.url, params: opt.params, retry: true, success: function (data) { opt.success(ServiceModel.returnData(data) ); }, failure: opt.failure, }); },
findAll: function(opt){ // we can enable certain error handling here // for when we need to reauthenticate. // // also explore local cached data, etc... return AD.ServiceJSON.post({ url: opt.url, params: opt.params, success: function (data) { opt.success(ServiceModel.returnData(data) ); }, failure: opt.failure, }); },