Skip to content
Browse files

[MOD-582] Stored Session Checking and Retrieval

To allow for synchronous session checking without a roundtrip to the server, plus exposure of the session string for manual calls to the ACS servers.

Note that this is not a guarantee of a valid session. Cloud.Users.showMe() is the only valid check for that.
  • Loading branch information...
1 parent b5c35cc commit 8dc798a379c7b7b0ff8ea4f2c8e95d128de8e47b Dawson Toth committed Apr 24, 2012
View
2 commonjs/documentation/changelog.md
@@ -1,5 +1,7 @@
# Change Log
<pre>
+v2.0.4 Added Cloud.Users.hasStoredSession() and Cloud.Users.retrieveStoredSession().
+
v2.0.3 Fixed URL encoding in Mobile Web [MOD-651].
v2.0.2 Fixed boolean parameter coercion corrupting computed Oauth signatures [MOD-609].
View
3 commonjs/example/windows/users/hasStoredSession.js
@@ -0,0 +1,3 @@
+windowFunctions['Has Stored Session'] = function () {
+ alert(Cloud.Users.hasStoredSession() ? 'Yes!' : 'No.');
+};
View
2 commonjs/example/windows/users/table.js
@@ -1,4 +1,5 @@
Ti.include(
+ 'hasStoredSession.js',
'create.js',
'login.js',
'logout.js',
@@ -18,6 +19,7 @@ windowFunctions['Users'] = function (evt) {
backgroundColor: '#fff',
top: offset + u,
data: createRows([
+ 'Has Stored Session',
'Create User',
'Login User',
'Request Reset Password',
View
2 commonjs/manifest
@@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
-version: 2.0.3
+version: 2.0.4
description: Appcelerator Cloud Services
author: Dawson Toth
license: Appcelerator Commercial License
View
22 commonjs/src/ti.cloud.js 100755 → 100644
@@ -20,7 +20,7 @@ else {
function defineCloud(Cloud) {
/*!
- * BedFrame v0.3 by Dawson Toth
+ * BedFrame v0.4 by Dawson Toth
* A framework for exposing RESTful APIs to Appcelerator Titanium Mobile.
*
* This framework is designed for REST APIs with the following characteristics:
@@ -114,7 +114,7 @@ function defineCloud(Cloud) {
return function () {
// Executors are designed to work based off of their context. Act upon the child, which is a mixed
// down result of its parent, and its parent's parent, and so on.
- child.executor.apply(child, arguments);
+ return child.executor.apply(child, arguments);
};
})(child);
}
@@ -187,6 +187,14 @@ function defineCloud(Cloud) {
}
);
}
+
+ function hasStoredSession() {
+ return ACS.hasStoredSession();
+ }
+
+ function retrieveStoredSession() {
+ return ACS.retrieveStoredSession();
+ }
function dataOptionalExecutor() {
defaultExecutor.call(this,
@@ -366,6 +374,8 @@ function defineCloud(Cloud) {
{
property: 'Users',
children: [
+ { method: 'hasStoredSession', executor: hasStoredSession },
+ { method: 'retrieveStoredSession', executor: retrieveStoredSession },
{ method: 'create', verb: 'POST' },
{ method: 'login', verb: 'POST' },
{ method: 'show' },
@@ -1501,6 +1511,14 @@ function defineCloud(Cloud) {
}
session.sendRequest(url, method, data, useSecure, callback);
};
+
+ ACS.hasStoredSession = function() {
+ return !!(com.acs.js.sdk.utils.retrieveSessionId());
+ };
+
+ ACS.retrieveStoredSession = function() {
+ return com.acs.js.sdk.utils.retrieveSessionId();
+ };
ACS.reset = function () {
com.acs.js.sdk.utils.clearSessionId();

0 comments on commit 8dc798a

Please sign in to comment.
Something went wrong with that request. Please try again.