You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by hm...@apache.org on 2012/10/08 12:02:21 UTC
svn commit: r1395499 - in /incubator/wookie/trunk/features/oauth: oauth.js
web/implicit.jsp
Author: hmt
Date: Mon Oct 8 10:02:21 2012
New Revision: 1395499
URL: http://svn.apache.org/viewvc?rev=1395499&view=rev
Log:
Adding callback to oauth feature when fail ou success
Modified:
incubator/wookie/trunk/features/oauth/oauth.js
incubator/wookie/trunk/features/oauth/web/implicit.jsp
Modified: incubator/wookie/trunk/features/oauth/oauth.js
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/features/oauth/oauth.js?rev=1395499&r1=1395498&r2=1395499&view=diff
==============================================================================
--- incubator/wookie/trunk/features/oauth/oauth.js (original)
+++ incubator/wookie/trunk/features/oauth/oauth.js Mon Oct 8 10:02:21 2012
@@ -16,6 +16,7 @@ oAuth = new function OAuth() {
this.access_token = null;
this.status = null; // null: init, O: not being authenticated, F: authentication failed, A: authenticated
this.oauthParams = new Object();
+ this.authCallback = null;
this.init = function() {
var info = new Object();
@@ -33,6 +34,24 @@ oAuth = new function OAuth() {
}, async: false});
}
}
+
+ // errorCode:
+ // * success
+ // p1: access_token, p2: expires time
+ // * other
+ // p1: error description
+ this.finishAuthProcess = function(error_code, p1, p2) {
+ var jResult = new Object();
+ if (error_code == 'success') {
+ oAuth.initAccessToken(p1, p2);
+ jResult['error'] = 'success';
+ } else {
+ jResult['error'] = error_code;
+ jResult['desc'] = p1;
+ }
+ if (oAuth.authCallback != null)
+ oAuth.authCallback(jResult);
+ }
this.initAccessToken = function(access_token, expires) {
// update to db if persist type
@@ -65,7 +84,7 @@ oAuth = new function OAuth() {
return returnedUrl;
}
- this.authenticate = function() {
+ this.authenticate = function(fCallback) {
// check if persist
if (oAuth.oauthParams['persist'] != 'false') {
OAuthConnector.queryToken(widget.instanceid_key,
@@ -90,7 +109,9 @@ oAuth = new function OAuth() {
if (typeof oAuth.oauthParams['scope'] != 'undefined') {
url += '&scope=' + oAuth.oauthParams['scope'];
}
-
+
+ this.authCallback = fCallback;
+
window.open(url, 'Authorization request',
'width=' + oAuth.oauthParams['popupWidth'] + ', height=' + oAuth.oauthParams['popupHeight']);
}
@@ -115,3 +136,4 @@ oAuth = new function OAuth() {
oAuth.init();
window.oauth = oAuth;
+
Modified: incubator/wookie/trunk/features/oauth/web/implicit.jsp
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/features/oauth/web/implicit.jsp?rev=1395499&r1=1395498&r2=1395499&view=diff
==============================================================================
Binary files - no diff available.