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) { ...@@ -12,7 +12,8 @@ function createRequestTypes(base, types = defaultTypes) {
export const LOGIN = createRequestTypes('LOGIN', [ export const LOGIN = createRequestTypes('LOGIN', [
...defaultTypes, ...defaultTypes,
'SET_SERVICES', 'SET_SERVICES',
'SET_PREFERENCE' 'SET_PREFERENCE',
'SET_LOCAL_AUTHENTICATED'
]); ]);
export const SHARE = createRequestTypes('SHARE', [ export const SHARE = createRequestTypes('SHARE', [
'SELECT_SERVER', 'SELECT_SERVER',
......
...@@ -49,3 +49,10 @@ export function setPreference(preference) { ...@@ -49,3 +49,10 @@ export function setPreference(preference) {
preference preference
}; };
} }
export function setLocalAuthenticated(isLocalAuthenticated) {
return {
type: types.LOGIN.SET_LOCAL_AUTHENTICATED,
isLocalAuthenticated
};
}
import * as types from '../actions/actionsTypes'; import * as types from '../actions/actionsTypes';
const initialState = { const initialState = {
isLocalAuthenticated: true,
isAuthenticated: false, isAuthenticated: false,
isFetching: false, isFetching: false,
user: {}, user: {},
...@@ -68,6 +69,11 @@ export default function login(state = initialState, action) { ...@@ -68,6 +69,11 @@ export default function login(state = initialState, action) {
} }
} }
}; };
case types.LOGIN.SET_LOCAL_AUTHENTICATED:
return {
...state,
isLocalAuthenticated: action.isLocalAuthenticated
};
default: default:
return state; return state;
} }
......
...@@ -34,6 +34,10 @@ const appHasComeBackToBackground = function* appHasComeBackToBackground() { ...@@ -34,6 +34,10 @@ const appHasComeBackToBackground = function* appHasComeBackToBackground() {
if (!auth) { if (!auth) {
return; return;
} }
const localAuthenticated = yield select(state => state.login.isLocalAuthenticated);
if (!localAuthenticated) {
return;
}
try { try {
const server = yield select(state => state.server.server); const server = yield select(state => state.server.server);
yield saveLastLocalAuthenticationSession(server); yield saveLastLocalAuthenticationSession(server);
......
...@@ -5,6 +5,7 @@ import AsyncStorage from '@react-native-community/async-storage'; ...@@ -5,6 +5,7 @@ import AsyncStorage from '@react-native-community/async-storage';
import RNUserDefaults from 'rn-user-defaults'; import RNUserDefaults from 'rn-user-defaults';
import { sha256 } from 'js-sha256'; import { sha256 } from 'js-sha256';
import store from '../lib/createStore';
import database from '../lib/database'; import database from '../lib/database';
import { isIOS } from './deviceInfo'; import { isIOS } from './deviceInfo';
import EventEmitter from './events'; import EventEmitter from './events';
...@@ -12,6 +13,7 @@ import { ...@@ -12,6 +13,7 @@ import {
LOCAL_AUTHENTICATE_EMITTER, LOCKED_OUT_TIMER_KEY, ATTEMPTS_KEY, PASSCODE_KEY, CHANGE_PASSCODE_EMITTER LOCAL_AUTHENTICATE_EMITTER, LOCKED_OUT_TIMER_KEY, ATTEMPTS_KEY, PASSCODE_KEY, CHANGE_PASSCODE_EMITTER
} from '../constants/localAuthentication'; } from '../constants/localAuthentication';
import I18n from '../i18n'; import I18n from '../i18n';
import { setLocalAuthenticated } from '../actions/login';
export const saveLastLocalAuthenticationSession = async(server, serverRecord) => { export const saveLastLocalAuthenticationSession = async(server, serverRecord) => {
const serversDB = database.servers; const serversDB = database.servers;
...@@ -100,6 +102,9 @@ export const localAuthenticate = async(server) => { ...@@ -100,6 +102,9 @@ export const localAuthenticate = async(server) => {
// if screen lock is enabled // if screen lock is enabled
if (serverRecord?.autoLock) { if (serverRecord?.autoLock) {
// set isLocalAuthenticated to false
store.dispatch(setLocalAuthenticated(false));
// Make sure splash screen has been hidden // Make sure splash screen has been hidden
RNBootSplash.hide(); RNBootSplash.hide();
...@@ -123,6 +128,9 @@ export const localAuthenticate = async(server) => { ...@@ -123,6 +128,9 @@ export const localAuthenticate = async(server) => {
// Authenticate // Authenticate
await openModal(hasBiometry); 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