1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-14 21:45:08 -05:00
kaiwa/public/js/oauthLogin.js

31 lines
994 B
JavaScript
Raw Normal View History

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 16:46:53 -04:00
wsURL: "wss://otalk.im/xmpp-websocket",
credentials: {
username: user.username.toLowerCase(),
password: token
}
});
window.location = '/';
},
error: function () {
window.location = '/logout';
}
});
}
});