Relog when ankiweb auth settings change
This commit is contained in:
parent
7d93587acb
commit
db918d3675
@ -75,6 +75,10 @@ class AnkiWeb {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logout() {
|
||||||
|
return AnkiWeb.loadPage('https://ankiweb.net/account/logout', null);
|
||||||
|
}
|
||||||
|
|
||||||
static scrape(username, password) {
|
static scrape(username, password) {
|
||||||
return AnkiWeb.loadAccountPage('https://ankiweb.net/edit/', null, username, password).then(response => {
|
return AnkiWeb.loadAccountPage('https://ankiweb.net/edit/', null, username, password).then(response => {
|
||||||
const modelsMatch = /editor\.models = (.*}]);/.exec(response);
|
const modelsMatch = /editor\.models = (.*}]);/.exec(response);
|
||||||
|
@ -198,12 +198,15 @@ function onOptionsChanged(e) {
|
|||||||
yomichan().setOptions(optsNew);
|
yomichan().setOptions(optsNew);
|
||||||
updateVisibility(optsNew);
|
updateVisibility(optsNew);
|
||||||
|
|
||||||
const invalidated =
|
const loginChanged =
|
||||||
optsNew.ankiMethod !== optsOld.ankiMethod ||
|
|
||||||
optsNew.ankiUsername !== optsOld.ankiUsername ||
|
optsNew.ankiUsername !== optsOld.ankiUsername ||
|
||||||
optsNew.ankiPassword !== optsOld.ankiPassword;
|
optsNew.ankiPassword !== optsOld.ankiPassword;
|
||||||
|
|
||||||
if (invalidated) {
|
if (loginChanged && optsNew.ankiMethod === 'ankiweb') {
|
||||||
|
anki().logout().then(() => populateAnkiDeckAndModel(optsNew)).catch(error => {
|
||||||
|
$('#anki-error').show().find('span').text(error);
|
||||||
|
});
|
||||||
|
} else if (loginChanged || optsNew.ankiMethod !== optsOld.ankiMethod) {
|
||||||
populateAnkiDeckAndModel(optsNew);
|
populateAnkiDeckAndModel(optsNew);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user