Unverified Commit 2cc599cc authored by Diego Mello's avatar Diego Mello Committed by GitHub
Browse files

[FIX] Screen Lock (#2177)



* [FIX] Screen Lock

* improve variable name
Co-authored-by: default avatarDjorkaeff Alexandre <djorkaeff.unb@gmail.com>
parent caf1ef2c
......@@ -12,7 +12,8 @@ function createRequestTypes(base, types = defaultTypes) {
export const LOGIN = createRequestTypes('LOGIN', [
...defaultTypes,
'SET_SERVICES',
'SET_PREFERENCE'
'SET_PREFERENCE',
'SET_LOCAL_AUTHENTICATED'
]);
export const SHARE = createRequestTypes('SHARE', [
'SELECT_SERVER',
......
......@@ -49,3 +49,10 @@ export function setPreference(preference) {
preference
};
}
export function setLocalAuthenticated(isLocalAuthenticated) {
return {
type: types.LOGIN.SET_LOCAL_AUTHENTICATED,
isLocalAuthenticated
};
}
import * as types from '../actions/actionsTypes';
const initialState = {
isLocalAuthenticated: true,
isAuthenticated: false,
isFetching: false,
user: {},
......@@ -68,6 +69,11 @@ export default function login(state = initialState, action) {
}
}
};
case types.LOGIN.SET_LOCAL_AUTHENTICATED:
return {
...state,
isLocalAuthenticated: action.isLocalAuthenticated
};
default:
return state;
}
......
......@@ -34,6 +34,10 @@ const appHasComeBackToBackground = function* appHasComeBackToBackground() {
if (!auth) {
return;
}
const localAuthenticated = yield select(state => state.login.isLocalAuthenticated);
if (!localAuthenticated) {
return;
}
try {
const server = yield select(state => state.server.server);
yield saveLastLocalAuthenticationSession(server);
......
......@@ -5,6 +5,7 @@ import AsyncStorage from '@react-native-community/async-storage';
import RNUserDefaults from 'rn-user-defaults';
import { sha256 } from 'js-sha256';
import store from '../lib/createStore';
import database from '../lib/database';
import { isIOS } from './deviceInfo';
import EventEmitter from './events';
......@@ -12,6 +13,7 @@ import {
LOCAL_AUTHENTICATE_EMITTER, LOCKED_OUT_TIMER_KEY, ATTEMPTS_KEY, PASSCODE_KEY, CHANGE_PASSCODE_EMITTER
} from '../constants/localAuthentication';
import I18n from '../i18n';
import { setLocalAuthenticated } from '../actions/login';
export const saveLastLocalAuthenticationSession = async(server, serverRecord) => {
const serversDB = database.servers;
......@@ -100,6 +102,9 @@ export const localAuthenticate = async(server) => {
// if screen lock is enabled
if (serverRecord?.autoLock) {
// set isLocalAuthenticated to false
store.dispatch(setLocalAuthenticated(false));
// Make sure splash screen has been hidden
RNBootSplash.hide();
......@@ -123,6 +128,9 @@ export const localAuthenticate = async(server) => {
// Authenticate
await openModal(hasBiometry);
// set isLocalAuthenticated to true
store.dispatch(setLocalAuthenticated(true));
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment