Files
cloudron-box/webadmin/js/controller/login.js
T
Johannes Zellner c7a00ea283 Use OAuth login in the webadmin
Currently the webadmin has a fixed built-in
client id, which is added on server startup.
2014-04-16 21:17:16 -07:00

26 lines
798 B
JavaScript
Executable File

'use strict';
function LoginController ($scope, Client) {
console.debug('LoginController');
// manually tell yellowtent to manage the signInButton
window.yellowtent.setupButton(document.getElementById('signInButton'), function (authCode) {
if (!authCode) {
console.error('User did not finish the OAuth flow.');
return;
}
console.debug('Got authCode as result of OAuth flow.', authCode);
Client.exchangeCodeForToken(authCode, function (error, accessToken) {
if (error) {
console.error('Unable to exchange code for an access token.', error);
return;
}
localStorage.token = accessToken;
window.location.href = '#/volumelist';
});
});
}