small fixes

This commit is contained in:
jeena 2013-10-02 11:42:47 +02:00
parent 1232994822
commit 2f8cc0d613

View file

@ -48,7 +48,7 @@ function(HostApp, APICalls, Hmac) {
} }
Oauth.prototype.isAuthenticated = function() { Oauth.prototype.isAuthenticated = function() {
return HostApp.stringForKey("user_access_token") != null; return !!HostApp.stringForKey("user_access_token");
} }
Oauth.prototype.authenticate = function() { Oauth.prototype.authenticate = function() {
@ -70,11 +70,11 @@ function(HostApp, APICalls, Hmac) {
} }
Oauth.prototype.requestProfileURL = function (entity) { Oauth.prototype.requestProfileURL = function (entity) {
var those = this; var _this = this;
APICalls.findProfileURL(entity, APICalls.findProfileURL(entity,
function(profile_url) { function(profile_url) {
if (profile_url && (profile_url.startsWith("http://") || profile_url.startsWith("https://"))) { if (profile_url && (profile_url.startsWith("http://") || profile_url.startsWith("https://"))) {
those.register(profile_url); _this.register(profile_url);
} else { } else {
HostApp.authentificationDidNotSucceed("Could not find profile for: " + entity); HostApp.authentificationDidNotSucceed("Could not find profile for: " + entity);
} }
@ -87,17 +87,17 @@ function(HostApp, APICalls, Hmac) {
} }
Oauth.prototype.register = function (url) { Oauth.prototype.register = function (url) {
var those = this; var _this = this;
APICalls.get(url, { APICalls.get(url, {
no_auth: true, no_auth: true,
callback: function(resp) { callback: function(resp) {
those.profile = JSON.parse(resp.responseText).post; _this.profile = JSON.parse(resp.responseText).post;
those.entity = those.profile.content.entity; _this.entity = _this.profile.content.entity;
HostApp.setStringForKey(those.entity, "entity") HostApp.setStringForKey(_this.entity, "entity")
HostApp.setServerUrls(those.profile.content.servers[0].urls); HostApp.setServerUrls(_this.profile.content.servers[0].urls);
APICalls.post(HostApp.serverUrl("new_post"), JSON.stringify(those.app_info), { APICalls.post(HostApp.serverUrl("new_post"), JSON.stringify(_this.app_info), {
content_type: "https://tent.io/types/app/v0#", content_type: "https://tent.io/types/app/v0#",
no_auth: true, no_auth: true,
callback: function(resp) { callback: function(resp) {
@ -111,7 +111,7 @@ function(HostApp, APICalls, Hmac) {
no_auth: true, no_auth: true,
callback: function(resp) { callback: function(resp) {
var data = JSON.parse(resp.responseText); var data = JSON.parse(resp.responseText);
those.authRequest(data.post, app_id); _this.authRequest(data.post, app_id);
} }
}); });
}}); }});