mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
fixes #941 - Rework password recovery and remove IsLocal checks
This commit is contained in:
parent
0adfd30015
commit
7f6f74fb54
11 changed files with 263 additions and 40 deletions
74
dashboard-ui/scripts/forgotpassword.js
Normal file
74
dashboard-ui/scripts/forgotpassword.js
Normal file
|
@ -0,0 +1,74 @@
|
|||
(function (window) {
|
||||
|
||||
function processForgotPasswordResult(page, result) {
|
||||
|
||||
if (result.Action == 'ContactAdmin') {
|
||||
|
||||
Dashboard.alert({
|
||||
|
||||
message: Globalize.translate('MessageContactAdminToResetPassword'),
|
||||
title: Globalize.translate('HeaderForgotPassword')
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.Action == 'InNetworkRequired') {
|
||||
|
||||
Dashboard.alert({
|
||||
|
||||
message: Globalize.translate('MessageForgotPasswordInNetworkRequired'),
|
||||
title: Globalize.translate('HeaderForgotPassword')
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.Action == 'PinCode') {
|
||||
|
||||
var msg = Globalize.translate('MessageForgotPasswordFileCreated');
|
||||
|
||||
msg += "<br/>";
|
||||
msg += "<br/>";
|
||||
msg += result.PinFile;
|
||||
msg += "<br/>";
|
||||
msg += "<br/>";
|
||||
msg += Globalize.translate('MessageForgotPasswordFileExpiration', parseISO8601Date(result.PinExpirationDate, { toLocal: true }).toLocaleString());
|
||||
|
||||
Dashboard.alert({
|
||||
|
||||
message: msg,
|
||||
title: Globalize.translate('HeaderForgotPassword')
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function onSubmit(page) {
|
||||
|
||||
ApiClient.ajax({
|
||||
|
||||
type: 'POST',
|
||||
url: ApiClient.getUrl('Users/ForgotPassword'),
|
||||
dataType: 'json',
|
||||
data: {
|
||||
EnteredUsername: $('#txtName', page).val()
|
||||
}
|
||||
|
||||
}).done(function (result) {
|
||||
|
||||
processForgotPasswordResult(page, result);
|
||||
});
|
||||
}
|
||||
|
||||
window.ForgotPasswordPage = {
|
||||
|
||||
onSubmit: function () {
|
||||
|
||||
var page = $(this).parents('.page');
|
||||
|
||||
onSubmit(page);
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
})(window);
|
63
dashboard-ui/scripts/forgotpasswordpin.js
Normal file
63
dashboard-ui/scripts/forgotpasswordpin.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
(function (window) {
|
||||
|
||||
function processForgotPasswordResult(page, result) {
|
||||
|
||||
if (result.Success) {
|
||||
|
||||
var msg = Globalize.translate('MessagePasswordResetForUsers');
|
||||
|
||||
msg += '<br/>';
|
||||
msg += '<br/>';
|
||||
msg += result.UsersReset.join('<br/>');
|
||||
|
||||
Dashboard.alert({
|
||||
|
||||
message: msg,
|
||||
title: Globalize.translate('HeaderPasswordReset'),
|
||||
|
||||
callback: function () {
|
||||
|
||||
window.location = 'login.html';
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Dashboard.alert({
|
||||
|
||||
message: Globalize.translate('MessageInvalidForgotPasswordPin'),
|
||||
title: Globalize.translate('HeaderPasswordReset')
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
function onSubmit(page) {
|
||||
|
||||
ApiClient.ajax({
|
||||
|
||||
type: 'POST',
|
||||
url: ApiClient.getUrl('Users/ForgotPassword/Pin'),
|
||||
dataType: 'json',
|
||||
data: {
|
||||
Pin: $('#txtPin', page).val()
|
||||
}
|
||||
|
||||
}).done(function (result) {
|
||||
|
||||
processForgotPasswordResult(page, result);
|
||||
});
|
||||
}
|
||||
|
||||
window.ForgotPasswordPinPage = {
|
||||
|
||||
onSubmit: function () {
|
||||
|
||||
var page = $(this).parents('.page');
|
||||
|
||||
onSubmit(page);
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
})(window);
|
|
@ -6,12 +6,6 @@
|
|||
|
||||
var page = this;
|
||||
|
||||
if (LoginPage.isLocalhost()) {
|
||||
$('.localhostMessage', page).show();
|
||||
} else {
|
||||
$('.localhostMessage', page).hide();
|
||||
}
|
||||
|
||||
// Show all users on localhost
|
||||
var promise1 = ApiClient.getPublicUsers();
|
||||
|
||||
|
@ -37,13 +31,7 @@
|
|||
});
|
||||
},
|
||||
|
||||
isLocalhost: function () {
|
||||
|
||||
var location = getWindowUrl().toString().toLowerCase();
|
||||
return location.indexOf('localhost') != -1 || location.indexOf('127.0.0.1') != -1;
|
||||
},
|
||||
|
||||
cancelLogin: function() {
|
||||
cancelLogin: function () {
|
||||
|
||||
LoginPage.showVisualForm($.mobile.activePage);
|
||||
},
|
||||
|
@ -52,7 +40,7 @@
|
|||
$('.visualLoginForm', page).hide();
|
||||
$('#manualLoginForm', page).show();
|
||||
$('#txtManualName', page).focus();
|
||||
|
||||
|
||||
if (showCancel) {
|
||||
$('.btnCancel', page).show();
|
||||
} else {
|
||||
|
@ -137,7 +125,7 @@
|
|||
|
||||
if (user.PrimaryImageTag) {
|
||||
|
||||
imgUrl = ApiClient.getUserImageUrl(user.Id, {
|
||||
imgUrl = ApiClient.getUserImageUrl(user.Id, {
|
||||
width: 300,
|
||||
tag: user.PrimaryImageTag,
|
||||
type: "Primary"
|
||||
|
@ -182,7 +170,7 @@
|
|||
var name = this.getAttribute('data-username');
|
||||
var haspw = this.getAttribute('data-haspw');
|
||||
|
||||
if (LoginPage.isLocalhost() || haspw == 'false') {
|
||||
if (haspw == 'false') {
|
||||
LoginPage.authenticateUserByName(name, '');
|
||||
} else {
|
||||
$('#txtManualName', page).val(name);
|
||||
|
|
|
@ -1242,9 +1242,6 @@ var Dashboard = {
|
|||
.on("websocketmessage.dashboard", Dashboard.onWebSocketMessageReceived)
|
||||
.on('requestfail.dashboard', Dashboard.onRequestFail)
|
||||
.on('serveraddresschanged.dashboard', Dashboard.onApiClientServerAddressChanged);
|
||||
|
||||
// TODO: Improve with http://webpjs.appspot.com/
|
||||
apiClient.supportsWebP($.browser.chrome);
|
||||
}
|
||||
|
||||
var appName = "Dashboard";
|
||||
|
@ -1447,7 +1444,7 @@ $(document).on('pagebeforeshow', ".page", function () {
|
|||
|
||||
else {
|
||||
|
||||
if (this.id !== "loginPage" && !page.hasClass('wizardPage') && !isConnectMode) {
|
||||
if (this.id !== "loginPage" && !page.hasClass('forgotPasswordPage') && !page.hasClass('wizardPage') && !isConnectMode) {
|
||||
|
||||
console.log('Not logged into server. Redirecting to login.');
|
||||
Dashboard.logout();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue