2013-09-13 00:28:59 -04:00
|
|
|
var parts = window.location.hash.slice(1).split('&');
|
|
|
|
|
|
|
|
parts.forEach(function (value) {
|
|
|
|
if (value.substr(0, 12) === "access_token") {
|
|
|
|
var token = value.substr(13);
|
|
|
|
$.ajax({
|
|
|
|
type: 'get',
|
|
|
|
url: 'https://api.andbang.com/me',
|
|
|
|
dataType: 'json',
|
|
|
|
headers: {
|
|
|
|
'Authorization': 'Bearer ' + token
|
|
|
|
},
|
|
|
|
success: function (user) {
|
|
|
|
localStorage.config = JSON.stringify({
|
|
|
|
jid: user.username.toLowerCase() + "@otalk.im",
|
|
|
|
server: "otalk.im",
|
2013-09-17 04:24:10 -04:00
|
|
|
wsURL: "wss://otalk.im:5281/xmpp-websocket",
|
2013-09-13 00:28:59 -04:00
|
|
|
credentials: {
|
|
|
|
username: user.username.toLowerCase(),
|
|
|
|
password: token
|
|
|
|
}
|
|
|
|
});
|
|
|
|
window.location = '/';
|
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
window.location = '/logout';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|