From 7f6f74fb54b82f201caa281e216aaed77ce335d7 Mon Sep 17 00:00:00 2001
From: Luke Pulverenti
Date: Sat, 8 Nov 2014 22:18:14 -0500
Subject: [PATCH] fixes #941 - Rework password recovery and remove IsLocal
checks
---
dashboard-ui/css/librarymenu.css | 1 +
dashboard-ui/css/site.css | 26 +++++++
dashboard-ui/forgotpassword.html | 43 +++++++++++
dashboard-ui/forgotpasswordpin.html | 42 +++++++++++
dashboard-ui/login.html | 8 +-
dashboard-ui/metadataadvanced.html | 4 +-
dashboard-ui/scripts/forgotpassword.js | 74 +++++++++++++++++++
dashboard-ui/scripts/forgotpasswordpin.js | 63 ++++++++++++++++
dashboard-ui/scripts/loginpage.js | 20 +----
dashboard-ui/scripts/site.js | 5 +-
.../apiclient/mediabrowser.apiclient.js | 17 -----
11 files changed, 263 insertions(+), 40 deletions(-)
create mode 100644 dashboard-ui/forgotpassword.html
create mode 100644 dashboard-ui/forgotpasswordpin.html
create mode 100644 dashboard-ui/scripts/forgotpassword.js
create mode 100644 dashboard-ui/scripts/forgotpasswordpin.js
diff --git a/dashboard-ui/css/librarymenu.css b/dashboard-ui/css/librarymenu.css
index e5f7d8d057..be97a83bb4 100644
--- a/dashboard-ui/css/librarymenu.css
+++ b/dashboard-ui/css/librarymenu.css
@@ -169,6 +169,7 @@
overflow-x: scroll;
-ms-overflow-style: none;
overflow: -moz-scrollbars-none;
+ -webkit-overflow-scrolling: touch;
}
.viewMenuBar {
diff --git a/dashboard-ui/css/site.css b/dashboard-ui/css/site.css
index 9a5363a0f2..6f38d31096 100644
--- a/dashboard-ui/css/site.css
+++ b/dashboard-ui/css/site.css
@@ -115,6 +115,32 @@ h1 a:hover {
font-weight: 400;
}
+/*
+ Make all panels vertically scrollable
+ If this causes any problems then perhaps require a css class to activate
+*/
+.ui-panel.ui-panel-open {
+ position: fixed;
+}
+
+.ui-panel-inner {
+ position: absolute;
+ top: 1px;
+ left: 0;
+ bottom: 0;
+ right: 0;
+ overflow: hidden;
+ overflow-y: scroll;
+ -webkit-overflow-scrolling: touch;
+ -ms-overflow-style: none;
+ overflow: -moz-scrollbars-none;
+}
+ .ui-panel-inner::-webkit-scrollbar {
+ width: 0 !important;
+ display: none;
+ }
+
+
pre, textarea.pre {
display: block;
padding: 8.5px;
diff --git a/dashboard-ui/forgotpassword.html b/dashboard-ui/forgotpassword.html
new file mode 100644
index 0000000000..87ee8e7b7e
--- /dev/null
+++ b/dashboard-ui/forgotpassword.html
@@ -0,0 +1,43 @@
+
+
+
+ ${TitleForgotPassword}
+
+
+
+
+
diff --git a/dashboard-ui/forgotpasswordpin.html b/dashboard-ui/forgotpasswordpin.html
new file mode 100644
index 0000000000..06b7523aa2
--- /dev/null
+++ b/dashboard-ui/forgotpasswordpin.html
@@ -0,0 +1,42 @@
+
+
+
+ ${TitlePasswordReset}
+
+
+
+
+
diff --git a/dashboard-ui/login.html b/dashboard-ui/login.html
index 89631bff7b..a7397f8b4b 100644
--- a/dashboard-ui/login.html
+++ b/dashboard-ui/login.html
@@ -27,13 +27,19 @@
${ButtonCancel}
+
+
+
+ ${ButtonForgotPassword}
+
+
diff --git a/dashboard-ui/metadataadvanced.html b/dashboard-ui/metadataadvanced.html
index ffbece16a2..23129d33bb 100644
--- a/dashboard-ui/metadataadvanced.html
+++ b/dashboard-ui/metadataadvanced.html
@@ -104,11 +104,11 @@
- ${ExtractChapterImagesHelp}
+ ${ExtractChapterImagesHelp}
-
+
diff --git a/dashboard-ui/scripts/forgotpassword.js b/dashboard-ui/scripts/forgotpassword.js
new file mode 100644
index 0000000000..dcd8a28c55
--- /dev/null
+++ b/dashboard-ui/scripts/forgotpassword.js
@@ -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 += "
";
+ msg += "
";
+ msg += result.PinFile;
+ msg += "
";
+ msg += "
";
+ 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);
\ No newline at end of file
diff --git a/dashboard-ui/scripts/forgotpasswordpin.js b/dashboard-ui/scripts/forgotpasswordpin.js
new file mode 100644
index 0000000000..65d5aa9ef6
--- /dev/null
+++ b/dashboard-ui/scripts/forgotpasswordpin.js
@@ -0,0 +1,63 @@
+(function (window) {
+
+ function processForgotPasswordResult(page, result) {
+
+ if (result.Success) {
+
+ var msg = Globalize.translate('MessagePasswordResetForUsers');
+
+ msg += '
';
+ msg += '
';
+ msg += result.UsersReset.join('
');
+
+ 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);
\ No newline at end of file
diff --git a/dashboard-ui/scripts/loginpage.js b/dashboard-ui/scripts/loginpage.js
index b47a9644c9..e47e482eca 100644
--- a/dashboard-ui/scripts/loginpage.js
+++ b/dashboard-ui/scripts/loginpage.js
@@ -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);
diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js
index 76b37ef913..d2b1425732 100644
--- a/dashboard-ui/scripts/site.js
+++ b/dashboard-ui/scripts/site.js
@@ -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();
diff --git a/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js b/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js
index 98b12360f5..0fc3ef7664 100644
--- a/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js
+++ b/dashboard-ui/thirdparty/apiclient/mediabrowser.apiclient.js
@@ -2285,15 +2285,6 @@
});
};
- var supportsWebP = false;
- self.supportsWebP = function (val) {
-
- if (val != null) {
- supportsWebP = val;
- }
- return supportsWebP;
- };
-
function normalizeImageOptions(options) {
var ratio = devicePixelRatio || 1;
@@ -2319,10 +2310,6 @@
}
options.quality = options.quality || (options.type.toLowerCase() == 'backdrop' ? 80 : 90);
-
- if (self.supportsWebP()) {
- options.format = 'webp';
- }
}
/**
@@ -2396,10 +2383,6 @@
delete options.type;
delete options.index;
- if (self.supportsWebP()) {
- options.format = 'webp';
- }
-
return self.getUrl(url, options);
};