mirror of
https://github.com/standardnotes/mobile.git
synced 2026-04-19 21:58:51 -04:00
Fix biometrics on quit (#371)
* Revert "fix: add default param for authenticate screen" This reverts commit01266879bd. * Revert "fix: biometrics shouldn't always show if set to on quit" This reverts commit5ed79e4810. * 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:
committed by
GitHub
parent
b46e6683ac
commit
1ed7d80fd2
@@ -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 });
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user