Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable 'Remember Me' by default [2.0] #2481

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"headroom.js": "^0.12.0",
"hls.js": "^0.14.17",
"intersection-observer": "^0.12.0",
"jellyfin-apiclient": "^1.6.0",
"jellyfin-apiclient": "git+https://github.com/dmitrylyzo/jellyfin-apiclient-javascript.git#remember-me",
"jquery": "^3.5.1",
"jstree": "^3.3.11",
"libarchive.js": "^1.3.0",
Expand Down
9 changes: 2 additions & 7 deletions src/components/appRouter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { appHost } from './apphost';
import appSettings from '../scripts/settings/appSettings';
import backdrop from './backdrop/backdrop';
import browser from '../scripts/browser';
import { Events } from 'jellyfin-apiclient';
Expand Down Expand Up @@ -98,9 +97,7 @@ class AppRouter {
beginConnectionWizard() {
backdrop.clearBackdrop();
loading.show();
ServerConnections.connect({
enableAutoLogin: appSettings.enableAutoLogin()
}).then((result) => {
ServerConnections.connect().then((result) => {
this.handleConnectionResult(result);
});
}
Expand Down Expand Up @@ -162,9 +159,7 @@ class AppRouter {
Events.on(appHost, 'beforeexit', this.onBeforeExit);
Events.on(appHost, 'resume', this.onAppResume);

ServerConnections.connect({
enableAutoLogin: appSettings.enableAutoLogin()
}).then((result) => {
ServerConnections.connect().then((result) => {
this.firstConnectionResult = result;
options = options || {};
page({
Expand Down
5 changes: 1 addition & 4 deletions src/controllers/session/addServer/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import appSettings from '../../../scripts/settings/appSettings';
import loading from '../../../components/loading/loading';
import globalize from '../../../scripts/globalize';
import '../../../elements/emby-button/emby-button';
Expand Down Expand Up @@ -38,9 +37,7 @@ import ServerConnections from '../../../components/ServerConnections';
function submitServer(page) {
loading.show();
const host = page.querySelector('#txtServerHost').value;
ServerConnections.connectToAddress(host, {
enableAutoLogin: appSettings.enableAutoLogin()
}).then(function(result) {
ServerConnections.connectToAddress(host).then(function(result) {
handleConnectionResult(page, result);
}, function() {
handleConnectionResult(page, {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/session/login/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1 class="sectionTitle">${HeaderPleaseSignIn}</h1>
</div>

<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" class="chkRememberLogin" checked />
<input is="emby-checkbox" type="checkbox" class="chkRememberLogin" />
<span>${RememberMe}</span>
</label>

Expand Down
14 changes: 6 additions & 8 deletions src/controllers/session/login/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { appHost } from '../../../components/apphost';
import appSettings from '../../../scripts/settings/appSettings';
import dom from '../../../scripts/dom';
import loading from '../../../components/loading/loading';
import layoutManager from '../../../components/layoutManager';
Expand All @@ -19,9 +18,9 @@ import cardBuilder from '../../../components/cardbuilder/cardBuilder';

const enableFocusTransform = !browser.slow && !browser.edge;

function authenticateUserByName(page, apiClient, username, password) {
function authenticateUserByName(page, apiClient, username, password, rememberMe) {
loading.show();
apiClient.authenticateUserByName(username, password).then(function (result) {
apiClient.authenticateUserByName(username, password, rememberMe).then(function (result) {
const user = result.User;
loading.hide();

Expand Down Expand Up @@ -76,7 +75,8 @@ import cardBuilder from '../../../components/cardbuilder/cardBuilder';
dialogHelper.close(dlg);
}

const result = await apiClient.quickConnect(data.Authentication);
// FIXME: Save token for now. 'Remember Me' for Quick Connect?
const result = await apiClient.quickConnect(data.Authentication, true);
onLoginSuccessful(result.User.Id, result.AccessToken, apiClient);
}, function (e) {
clearInterval(interval);
Expand Down Expand Up @@ -114,7 +114,6 @@ import cardBuilder from '../../../components/cardbuilder/cardBuilder';
}

function showManualForm(context, showCancel, focusPassword) {
context.querySelector('.chkRememberLogin').checked = appSettings.enableAutoLogin();
context.querySelector('.manualLoginForm').classList.remove('hide');
context.querySelector('.visualLoginForm').classList.add('hide');
context.querySelector('.btnManual').classList.add('hide');
Expand Down Expand Up @@ -218,7 +217,7 @@ import cardBuilder from '../../../components/cardbuilder/cardBuilder';
context.querySelector('#txtManualName').value = '';
showManualForm(context, true);
} else if (haspw == 'false') {
authenticateUserByName(context, getApiClient(), name, '');
authenticateUserByName(context, getApiClient(), name, '', false);
} else {
context.querySelector('#txtManualName').value = name;
context.querySelector('#txtManualPassword').value = '';
Expand All @@ -227,9 +226,8 @@ import cardBuilder from '../../../components/cardbuilder/cardBuilder';
}
});
view.querySelector('.manualLoginForm').addEventListener('submit', function (e) {
appSettings.enableAutoLogin(view.querySelector('.chkRememberLogin').checked);
const apiClient = getApiClient();
authenticateUserByName(view, apiClient, view.querySelector('#txtManualName').value, view.querySelector('#txtManualPassword').value);
authenticateUserByName(view, apiClient, view.querySelector('#txtManualName').value, view.querySelector('#txtManualPassword').value, view.querySelector('.chkRememberLogin').checked);
e.preventDefault();
return false;
});
Expand Down
5 changes: 1 addition & 4 deletions src/controllers/session/selectServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import loading from '../../../components/loading/loading';
import { appRouter } from '../../../components/appRouter';
import layoutManager from '../../../components/layoutManager';
import libraryMenu from '../../../scripts/libraryMenu';
import appSettings from '../../../scripts/settings/appSettings';
import focusManager from '../../../components/focusManager';
import globalize from '../../../scripts/globalize';
import actionSheet from '../../../components/actionSheet/actionSheet';
Expand Down Expand Up @@ -114,9 +113,7 @@ import cardBuilder from '../../../components/cardbuilder/cardBuilder';
export default function (view, params) {
function connectToServer(server) {
loading.show();
ServerConnections.connectToServer(server, {
enableAutoLogin: appSettings.enableAutoLogin()
}).then(function (result) {
ServerConnections.connectToServer(server).then(function (result) {
loading.hide();
const apiClient = result.ApiClient;

Expand Down
8 changes: 0 additions & 8 deletions src/scripts/settings/appSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ class AppSettings {
return name;
}

enableAutoLogin(val) {
if (val !== undefined) {
this.set('enableAutoLogin', val.toString());
}

return this.get('enableAutoLogin') !== 'false';
}

enableSystemExternalPlayers(val) {
if (val !== undefined) {
this.set('enableSystemExternalPlayers', val.toString());
Expand Down