mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
completed auth database
This commit is contained in:
parent
3719b9ad8e
commit
10414ce9ac
9 changed files with 135 additions and 101 deletions
|
@ -6,25 +6,22 @@
|
|||
|
||||
var page = this;
|
||||
|
||||
var location = window.location.toString().toLowerCase();
|
||||
var isLocalhost = location.indexOf('localhost') != -1 || location.indexOf('127.0.0.1') != -1;
|
||||
|
||||
if (isLocalhost) {
|
||||
if (LoginPage.isLocalhost()) {
|
||||
$('.localhostMessage', page).show();
|
||||
} else {
|
||||
$('.localhostMessage', page).hide();
|
||||
}
|
||||
|
||||
// Show all users on localhost
|
||||
var promise1 = !isLocalhost ? ApiClient.getPublicUsers() : ApiClient.getUsers({ IsDisabled: false });
|
||||
var promise1 = ApiClient.getPublicUsers();
|
||||
|
||||
promise1.done(function (users) {
|
||||
|
||||
var showManualForm = !users.length || !isLocalhost;
|
||||
var showManualForm = !users.length;
|
||||
|
||||
if (showManualForm) {
|
||||
|
||||
LoginPage.showManualForm(page);
|
||||
LoginPage.showManualForm(page, false);
|
||||
|
||||
} else {
|
||||
LoginPage.showVisualForm(page);
|
||||
|
@ -40,10 +37,27 @@
|
|||
});
|
||||
},
|
||||
|
||||
showManualForm: function (page) {
|
||||
isLocalhost: function () {
|
||||
|
||||
var location = window.location.toString().toLowerCase();
|
||||
return location.indexOf('localhost') != -1 || location.indexOf('127.0.0.1') != -1;
|
||||
},
|
||||
|
||||
cancelLogin: function() {
|
||||
|
||||
LoginPage.showVisualForm($.mobile.activePage);
|
||||
},
|
||||
|
||||
showManualForm: function (page, showCancel) {
|
||||
$('.visualLoginForm', page).hide();
|
||||
$('#manualLoginForm', page).show();
|
||||
$('#txtManualName', page).focus();
|
||||
|
||||
if (showCancel) {
|
||||
$('.btnCancel', page).show();
|
||||
} else {
|
||||
$('.btnCancel', page).hide();
|
||||
}
|
||||
},
|
||||
|
||||
showVisualForm: function (page) {
|
||||
|
@ -73,22 +87,6 @@
|
|||
});
|
||||
},
|
||||
|
||||
authenticateUserLink: function (link) {
|
||||
|
||||
LoginPage.authenticateUser(link.getAttribute('data-userid'));
|
||||
},
|
||||
|
||||
authenticateUser: function (userId, password) {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.getUser(userId).done(function (user) {
|
||||
|
||||
LoginPage.authenticateUserByName(user.Name, password);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
authenticateUserByName: function (username, password) {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
@ -97,12 +95,12 @@
|
|||
|
||||
var user = result.User;
|
||||
|
||||
Dashboard.setCurrentUser(user.Id);
|
||||
Dashboard.setCurrentUser(user.Id, result.AccessToken);
|
||||
|
||||
if (user.Configuration.IsAdministrator) {
|
||||
window.location = "dashboard.html?u=" + user.Id;
|
||||
window.location = "dashboard.html?u=" + user.Id + '&t=' + result.AccessToken;
|
||||
} else {
|
||||
window.location = "index.html?u=" + user.Id;
|
||||
window.location = "index.html?u=" + user.Id + '&t=' + result.AccessToken;
|
||||
}
|
||||
|
||||
}).fail(function () {
|
||||
|
@ -123,12 +121,14 @@
|
|||
loadUserList: function (users) {
|
||||
var html = "";
|
||||
|
||||
var page = $.mobile.activePage;
|
||||
|
||||
for (var i = 0, length = users.length; i < length; i++) {
|
||||
var user = users[i];
|
||||
|
||||
var linkId = "lnkUser" + i;
|
||||
|
||||
html += "<a class='posterItem squarePosterItem' id='" + linkId + "' data-userid='" + user.Id + "' href='index.html?u=" + user.Id + "' data-ajax='false' \">";
|
||||
html += "<a class='posterItem squarePosterItem' id='" + linkId + "' data-haspw='" + user.HasPassword + "' data-username='" + user.Name + "' data-userid='" + user.Id + "' href='#' data-ajax='false' \">";
|
||||
|
||||
if (user.PrimaryImageTag) {
|
||||
|
||||
|
@ -162,8 +162,21 @@
|
|||
html += '</a>';
|
||||
}
|
||||
|
||||
$('#divUsers', '#loginPage').html(html);
|
||||
var elem = $('#divUsers', '#loginPage').html(html);
|
||||
|
||||
$('.posterItem', elem).on('click', function () {
|
||||
|
||||
var name = this.getAttribute('data-username');
|
||||
var haspw = this.getAttribute('data-haspw');
|
||||
|
||||
if (LoginPage.isLocalhost() || haspw == 'false') {
|
||||
LoginPage.authenticateUserByName(name, '');
|
||||
} else {
|
||||
$('#txtManualName', page).val(name);
|
||||
$('#txtManualPassword', '#loginPage').val('');
|
||||
LoginPage.showManualForm(page, true);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onManualSubmit: function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue