Fix biometrics on quit (#371)

* Revert "fix: add default param for authenticate screen"

This reverts commit 01266879bd.

* Revert "fix: biometrics shouldn't always show if set to on quit"

This reverts commit 5ed79e4810.

* fix: biometrics shouldn't always show if set to on quit

* fix: add prompt type and remove log

* refactor: changes per PR feedback

* refactor: remove unnecessary set to false

* refactor: return undefined instead of null

* refactor: always set previouslyLaunched to true

* chore: upgrade snjs version
This commit is contained in:
Antonella Sgarlatta
2021-02-24 17:00:08 -03:00
committed by GitHub
parent b46e6683ac
commit 1ed7d80fd2
4 changed files with 50 additions and 8 deletions

View File

@@ -26,7 +26,7 @@
"@react-navigation/native": "^5.8.10",
"@react-navigation/stack": "^5.12.8",
"@standardnotes/sncrypto-common": "1.2.9",
"@standardnotes/snjs": "^2.0.57",
"@standardnotes/snjs": "^2.0.59",
"js-base64": "^3.5.2",
"moment": "^2.29.1",
"react": "16.13.1",

View File

@@ -1,6 +1,9 @@
import { SCREEN_AUTHENTICATE } from '@Screens/screens';
import {
Challenge,
ChallengePrompt,
ChallengeReason,
ChallengeValidation,
DeinitSource,
Environment,
platformFromString,
@@ -10,7 +13,7 @@ import {
import { Platform } from 'react-native';
import VersionInfo from 'react-native-version-info';
import { AlertService } from './alert_service';
import { ApplicationState } from './application_state';
import { ApplicationState, UnlockTiming } from './application_state';
import { BackupsService } from './backups_service';
import { ComponentGroup } from './component_group';
import { ComponentManager } from './component_manager';
@@ -39,6 +42,8 @@ export class MobileApplication extends SNApplication {
private startedDeinit: boolean = false;
public Uuid: string; // UI remounts when Uuid changes
static previouslyLaunched: boolean = false;
constructor(deviceInterface: MobileDeviceInterface, identifier: string) {
super(
Environment.Mobile,
@@ -63,6 +68,14 @@ export class MobileApplication extends SNApplication {
this.componentGroup = new ComponentGroup(this);
}
static getPreviouslyLaunched() {
return this.previouslyLaunched;
}
static setPreviouslyLaunched() {
this.previouslyLaunched = true;
}
public hasStartedDeinit() {
return this.startedDeinit;
}
@@ -83,6 +96,33 @@ export class MobileApplication extends SNApplication {
super.deinit(source);
}
/** @override */
getLaunchChallenge() {
const challenge = super.getLaunchChallenge();
if (!challenge) {
return undefined;
}
const previouslyLaunched = MobileApplication.getPreviouslyLaunched();
const biometricsTiming = this.getAppState().biometricsTiming;
if (previouslyLaunched && biometricsTiming === UnlockTiming.OnQuit) {
const filteredPrompts = challenge.prompts.filter(
(prompt: ChallengePrompt) =>
prompt.validation !== ChallengeValidation.Biometric
);
return new Challenge(
filteredPrompts,
ChallengeReason.ApplicationUnlock,
false
);
}
return challenge;
}
promptForChallenge(challenge: Challenge) {
push(SCREEN_AUTHENTICATE, { challenge, title: challenge.modalTitle });
}

View File

@@ -171,10 +171,12 @@ export class ApplicationState extends ApplicationService {
}
}
);
await this.loadUnlockTiming();
}
async onAppLaunch() {
await this.getUnlockTiming();
MobileApplication.setPreviouslyLaunched();
this.setScreenshotPrivacy();
}
@@ -248,7 +250,7 @@ export class ApplicationState extends ApplicationService {
}
}
private async getUnlockTiming() {
private async loadUnlockTiming() {
this.passcodeTiming = await this.getPasscodeTiming();
this.biometricsTiming = await this.getBiometricsTiming();
}

View File

@@ -1385,10 +1385,10 @@
resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-common/-/sncrypto-common-1.2.9.tgz#5212a959e4ec563584e42480bfd39ef129c3cbdf"
integrity sha512-xJ5IUGOZztjSgNP/6XL+Ut5+q9UgSTv6xMtKkcQC5aJxCOkJy9u6RamPLdF00WQgwibxx2tu0e43bKUjTgzMig==
"@standardnotes/snjs@^2.0.57":
version "2.0.57"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.57.tgz#758d30d9074aa463ca2b642783d929a10a1a1c9f"
integrity sha512-s2FP024TziZnt0nJ10Tbja3IQ2KOITA67EGchadAN+vapXEicTDX2MSCPzlvk2D1M494zu15vWwQX1ryeHvHHA==
"@standardnotes/snjs@^2.0.59":
version "2.0.59"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.59.tgz#ff9b60407d7810910d9bcc92e3db6bede5f28f1f"
integrity sha512-qt6C7KOapNaMFv+thy37scgpD/66NEwlY/RddSwxQzKFP9VWY39LYYVuDOhVgDVg18+8cK38rMTRtJag11Xy0Q==
dependencies:
"@standardnotes/sncrypto-common" "^1.2.9"