first attempt, login working, getting some data working
This commit is contained in:
parent
876cf8f268
commit
6caee6de79
6 changed files with 276 additions and 33 deletions
63
js/Login.js
63
js/Login.js
|
@ -1,11 +1,10 @@
|
|||
function Login(app) {
|
||||
this.app = app;
|
||||
|
||||
if(!this.is_logged_in()) {
|
||||
this.log_in();
|
||||
if(!this.onLine()) alert("You need to be on line to log in to your server.");
|
||||
}
|
||||
else this.app.after_login();
|
||||
else this.app.after_login(localStorage.backend);
|
||||
};
|
||||
|
||||
Login.prototype.onLine = function() {
|
||||
|
@ -13,7 +12,7 @@ Login.prototype.onLine = function() {
|
|||
};
|
||||
|
||||
Login.prototype.is_logged_in = function() {
|
||||
return localStorage.server_url && localStorage.session_id;
|
||||
return localStorage.backend && localStorage.server_url && localStorage.session_id;
|
||||
};
|
||||
|
||||
Login.prototype.log_in = function() {
|
||||
|
@ -45,26 +44,46 @@ Login.prototype.authenticate = function(e) {
|
|||
}
|
||||
|
||||
var _this = this;
|
||||
TinyTinyRSS.login(server_url, user, password, function(data) {
|
||||
if(data.error) {
|
||||
if(data.error == "API_DISABLED") {
|
||||
alert("You need to enable API access in your TTRSS preferences.\n\nTo do so go to your server log in and then in Preferences -> General -> Enable API access. Check the box and save. Then try again to log in.")
|
||||
} else if(data.error == "LOGIN_ERROR") {
|
||||
alert("Login error\n\nIt seems you provided a wrong username or password.")
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
if(true) {
|
||||
OwnCloud.login(server_url, user, password, function(data) {
|
||||
if(data.version) {
|
||||
var auth = btoa(user + ':' + password);
|
||||
localStorage.server_url = server_url;
|
||||
localStorage.session_id = auth;
|
||||
localStorage.backend = "OwnCloud";
|
||||
_this.app.after_login(localStorage.backend);
|
||||
|
||||
} else {
|
||||
localStorage.server_url = server_url;
|
||||
localStorage.session_id = data.session_id;
|
||||
_this.app.after_login();
|
||||
|
||||
$("#url").value = "";
|
||||
$("#un").value = "";
|
||||
$("#pw").value = "";
|
||||
}
|
||||
});
|
||||
$("#url").value = "";
|
||||
$("#un").value = "";
|
||||
$("#pw").value = "";
|
||||
} else {
|
||||
alert("Something went wrong, please check every input field and try again.");
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
TinyTinyRSS.login(server_url, user, password, function(data) {
|
||||
if(data.error) {
|
||||
if(data.error == "API_DISABLED") {
|
||||
alert("You need to enable API access in your TTRSS preferences.\n\nTo do so go to your server log in and then in Preferences -> General -> Enable API access. Check the box and save. Then try again to log in.")
|
||||
} else if(data.error == "LOGIN_ERROR") {
|
||||
alert("Login error\n\nIt seems you provided a wrong username or password.")
|
||||
} else {
|
||||
alert(data.error);
|
||||
}
|
||||
|
||||
} else {
|
||||
localStorage.server_url = server_url;
|
||||
localStorage.session_id = data.session_id;
|
||||
localStorage.backend = "TinyTinyRSS";
|
||||
_this.app.after_login(localStorage.backend);
|
||||
|
||||
$("#url").value = "";
|
||||
$("#un").value = "";
|
||||
$("#pw").value = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
|
Reference in a new issue