Created
April 23, 2009 18:58
-
-
Save jamierumbelow/100692 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Jitterbug | |
auth.js - basic authentication | |
by Jamie Rumbelow | |
Thanks for checking out the source! | |
Copyright (c)2009 JR and JG. Init. | |
*/ | |
function auth() { | |
if ($SESSION) { | |
return true; | |
} | |
else { | |
if (widget.preferenceForKey('jitterbug_user')) { | |
var user = widget.preferenceForKey('jitterbug_user'), | |
pin = widget.preferenceForKey('jitterbug_pin'), | |
url = $api.url + "userAuthenticate" + "?" + obj2query({'id': user, 'pin': pin}); | |
getJSONP(url, function(response){ | |
$SESSION = response.session_id; | |
return true; | |
}); | |
while ($SESSION == "") { } | |
} | |
else { | |
var url = $api.url + "userCreate"; | |
getJSONP(url, function(response){ | |
$SESSION = response.session_id; | |
widget.setPreferenceForKey(response.user_id, 'jitterbug_user'); | |
widget.setPreferenceForKey(response.user_pin, 'jitterbug_pin'); | |
return true; | |
}); | |
while ($SESSION == "") { } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment