Issue #30 : Keep the username in localStorage, so that the user does not have to type it again in case his session has expired
+ also fill the login form with the localStorage values when the user chooses to logout
This commit is contained in:
parent
3f75c49e3e
commit
b2f319af71
2 changed files with 20 additions and 2 deletions
|
@ -168,9 +168,8 @@ App.prototype.gotUnreadFeeds = function(new_articles) {
|
|||
// user to login again if it is the case.
|
||||
// This can happen with TT-RSS backend
|
||||
if (new_articles.error && new_articles.error === "NOT_LOGGED_IN") {
|
||||
$("#url").value = localStorage.server_url;
|
||||
$("#login form").backend[0].checked = true;
|
||||
alert("Your TinyTinyRSS session has expired. Please login again");
|
||||
this.login.fillLoginFormFromLocalSotrage();
|
||||
this.login.log_in();
|
||||
}
|
||||
else {
|
||||
|
|
19
js/Login.js
19
js/Login.js
|
@ -67,6 +67,7 @@ Login.prototype.authenticate = function(e) {
|
|||
if(data.version) {
|
||||
var auth = btoa(user + ':' + password);
|
||||
localStorage.server_url = server_url;
|
||||
localStorage.username = user;
|
||||
localStorage.session_id = auth;
|
||||
localStorage.backend = "OwnCloud";
|
||||
_this.app.after_login(localStorage.backend);
|
||||
|
@ -83,6 +84,7 @@ Login.prototype.authenticate = function(e) {
|
|||
Pond.login(server_url, user, password, function(data) {
|
||||
if(data.session_token) {
|
||||
localStorage.server_url = server_url;
|
||||
localStorage.username = user;
|
||||
localStorage.session_id = data.session_token;
|
||||
localStorage.backend = "Pond";
|
||||
_this.app.after_login(localStorage.backend);
|
||||
|
@ -106,6 +108,7 @@ Login.prototype.authenticate = function(e) {
|
|||
|
||||
} else {
|
||||
localStorage.server_url = server_url;
|
||||
localStorage.username = user;
|
||||
localStorage.session_id = data.session_id;
|
||||
localStorage.backend = "TinyTinyRSS";
|
||||
_this.app.after_login(localStorage.backend);
|
||||
|
@ -120,7 +123,23 @@ Login.prototype.authenticate = function(e) {
|
|||
return false;
|
||||
};
|
||||
|
||||
Login.prototype.fillLoginFormFromLocalSotrage = function() {
|
||||
$("#url").value = localStorage.server_url;
|
||||
$("#un").value = localStorage.username;
|
||||
var backendName = localStorage.backend;
|
||||
if (backendName === "TinyTinyRSS") {
|
||||
$("#login form").backend[0].checked = true;
|
||||
}
|
||||
else if (backendName === "OwnCloud") {
|
||||
$("#login form").backend[1].checked = true;
|
||||
}
|
||||
else if (backendName === "Pond") {
|
||||
$("#login form").backend[2].checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
Login.prototype.log_out = function() {
|
||||
this.fillLoginFormFromLocalSotrage();
|
||||
localStorage.removeItem("server_url");
|
||||
localStorage.removeItem("session_id");
|
||||
localStorage.removeItem("unread_articles");
|
||||
|
|
Reference in a new issue