Merge pull request #24 from ngokevin/secrettoken

hook up login + logout with zamboni (bug 970598)
This commit is contained in:
Kevin Ngo 2014-04-04 17:45:52 -07:00
Родитель e05cb416a3 0fc5bddc64
Коммит af958089a0
5 изменённых файлов: 37 добавлений и 22 удалений

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "commonplace",
"version": "0.2.9",
"version": "0.3.0",
"preferGlobal": true,
"repository": {
"url": "git://github.com/mozilla/commonplace.git",

Просмотреть файл

@ -23,26 +23,31 @@ define('login',
}).on('click', '.logout', function(e) {
e.preventDefault();
user.clear_token();
z.body.removeClass('logged-in');
z.page.trigger('reload_chrome').trigger('before_logout');
if (capabilities.persona) {
console.log('Triggering Persona logout');
navigator.id.logout();
}
requests.del(urls.api.url('logout')).done(function() {
// Moved here from the onlogout callback for now until
// https://github.com/mozilla/browserid/issues/3229
// gets fixed.
user.clear_token();
z.body.removeClass('logged-in');
z.page.trigger('reload_chrome').trigger('before_logout');
// Moved here from the onlogout callback for now until
// https://github.com/mozilla/browserid/issues/3229
// gets fixed.
if (!z.context.dont_reload_on_login) {
require('views').reload().done(function(){
z.page.trigger('logged_out');
signOutNotification();
});
} else {
console.log('Reload on logout aborted by current view');
}
if (capabilities.persona) {
console.log('Triggering Persona logout');
navigator.id.logout();
}
if (!z.context.dont_reload_on_login) {
require('views').reload().done(function(){
z.page.trigger('logged_out');
signOutNotification();
});
} else {
console.log('Reload on logout aborted by current view');
}
}).fail(function() {
notification.notification({message: gettext('Error signing out')});
});
});
var pending_logins = [];

Просмотреть файл

@ -7,5 +7,7 @@ define('routes_api', [], function() {
// "another_route": "/foo/bar/{0}/asdf"
// }
return {
'login': '/api/v1/account/login/',
'logout': '/api/v1/account/logout/',
};
});

Просмотреть файл

@ -17,6 +17,14 @@ define('storage', ['settings'], function(settings) {
};
}
// Expose storage version (which is prefixed to every key).
// For instance, used in Zamboni login.js.
try {
ls.setItem('latestStorageVersion', settings.storage_version);
} catch(e) {
fakeStorage.latestStorageVersion = settings.storage_version;
}
return {
clear: function() {
try { ls.clear(); }

Просмотреть файл

@ -16,17 +16,17 @@ define('user',
var save_to_ls = !capabilities.phantom;
if (save_to_ls) {
// Try to initialize items from localStorage.
token = storage.getItem('user');
log.unmention(token);
settings = JSON.parse(storage.getItem('settings') || '{}');
permissions = JSON.parse(storage.getItem('permissions') || '{}');
var _stored = storage.getItem('user_apps');
if (_stored) {
apps = JSON.parse(_stored);
}
}
if (save_to_ls) {
log.unmention(token);
save_settings();
}