Skip to content
Merged
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
25 changes: 0 additions & 25 deletions app/constants/localAuthentication.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import I18n from '../i18n';

export const PASSCODE_KEY = 'kPasscode';
export const LOCKED_OUT_TIMER_KEY = 'kLockedOutTimer';
export const ATTEMPTS_KEY = 'kAttempts';
Expand All @@ -12,26 +10,3 @@ export const MAX_ATTEMPTS = 6;
export const TIME_TO_LOCK = 30000;

export const DEFAULT_AUTO_LOCK = 1800;

export const DEFAULT_AUTO_LOCK_OPTIONS = [
{
title: I18n.t('Local_authentication_auto_lock_60'),
value: 60
},
{
title: I18n.t('Local_authentication_auto_lock_300'),
value: 300
},
{
title: I18n.t('Local_authentication_auto_lock_900'),
value: 900
},
{
title: I18n.t('Local_authentication_auto_lock_1800'),
value: 1800
},
{
title: I18n.t('Local_authentication_auto_lock_3600'),
value: 3600
}
];
15 changes: 1 addition & 14 deletions app/lib/methods/getSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import log from '../../utils/log';
import database from '../database';
import protectedFunction from './helpers/protectedFunction';
import fetch from '../../utils/fetch';
import { DEFAULT_AUTO_LOCK, DEFAULT_AUTO_LOCK_OPTIONS } from '../../constants/localAuthentication';
import { DEFAULT_AUTO_LOCK } from '../../constants/localAuthentication';

const serverInfoKeys = ['Site_Name', 'UI_Use_Real_Name', 'FileUpload_MediaTypeWhiteList', 'FileUpload_MaxFileSize', 'Force_Screen_Lock', 'Force_Screen_Lock_After'];

Expand Down Expand Up @@ -55,19 +55,6 @@ const serverInfoUpdate = async(serverInfo, iconSetting) => {
return { ...allSettings, autoLock };
}
if (setting._id === 'Force_Screen_Lock_After') {
// Force_Screen_Lock from server
const forceScreenLock = serverInfo.find(item => item._id === 'Force_Screen_Lock')?.valueAsBoolean;

// if Force_Screen_Lock is disabled on server and Screen Lock is enabled on app
if (!forceScreenLock && server.autoLock) {
// if the current autoLockTime is one of our default options, we'll keep this value
if (DEFAULT_AUTO_LOCK_OPTIONS.find(option => option.value === server.autoLockTime)) {
return { ...allSettings, autoLockTime: server.autoLockTime };
}
// if the current autoLockTime is a value that isn't in our default options, we'll reset
return { ...allSettings, autoLockTime: DEFAULT_AUTO_LOCK };
}

// if Force_Screen_Lock_After === 0 and autoLockTime is null, set app's default value
if (setting.valueAsNumber === 0 && !server.autoLockTime) {
return { ...allSettings, autoLockTime: DEFAULT_AUTO_LOCK };
Expand Down
35 changes: 32 additions & 3 deletions app/views/ScreenLockConfigView.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CustomIcon } from '../lib/Icons';
import database from '../lib/database';
import { supportedBiometryLabel, changePasscode, checkHasPasscode } from '../utils/localAuthentication';
import { DisclosureImage } from '../containers/DisclosureIndicator';
import { DEFAULT_AUTO_LOCK_OPTIONS, DEFAULT_AUTO_LOCK } from '../constants/localAuthentication';
import { DEFAULT_AUTO_LOCK } from '../constants/localAuthentication';

const styles = StyleSheet.create({
listPadding: {
Expand Down Expand Up @@ -54,6 +54,29 @@ class ScreenLockConfigView extends React.Component {
this.init();
}

defaultAutoLockOptions = [
{
title: I18n.t('Local_authentication_auto_lock_60'),
value: 60
},
{
title: I18n.t('Local_authentication_auto_lock_300'),
value: 300
},
{
title: I18n.t('Local_authentication_auto_lock_900'),
value: 900
},
{
title: I18n.t('Local_authentication_auto_lock_1800'),
value: 1800
},
{
title: I18n.t('Local_authentication_auto_lock_3600'),
value: 3600
}
];

init = async() => {
const { server } = this.props;
const serversDB = database.servers;
Expand Down Expand Up @@ -168,18 +191,24 @@ class ScreenLockConfigView extends React.Component {
}

renderAutoLockItems = () => {
const { autoLock } = this.state;
const { autoLock, autoLockTime } = this.state;
const { theme, Force_Screen_Lock_After, Force_Screen_Lock } = this.props;
if (!autoLock) {
return null;
}
let items = DEFAULT_AUTO_LOCK_OPTIONS;
let items = this.defaultAutoLockOptions;
if (Force_Screen_Lock && Force_Screen_Lock_After > 0) {
items = [{
title: I18n.t('After_seconds_set_by_admin', { seconds: Force_Screen_Lock_After }),
value: Force_Screen_Lock_After,
disabled: true
}];
// if Force_Screen_Lock is disabled and autoLockTime is a value that isn't on our defaultOptions we'll show it
} else if (Force_Screen_Lock_After === autoLockTime && !items.find(item => item.value === autoLockTime)) {
items.push({
title: I18n.t('After_seconds_set_by_admin', { seconds: Force_Screen_Lock_After }),
value: Force_Screen_Lock_After
});
}
return (
<>
Expand Down