Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("passes when used properly", () => {
FingerprintScanner.authenticate({
description: "Any string",
fallbackEnabled: true
});
FingerprintScanner.authenticate({
description: "Any string"
});
FingerprintScanner.authenticate({
fallbackEnabled: true
});
});
async componentDidMount () {
if (!this.props.isLocked) {
this.props.history.push('/dashboard')
return
}
try {
let isAvailable = await FingerprintScanner.isSensorAvailable()
if (!isAvailable) {
this.setState({ sensorAvail: isAvailable })
} else {
await FingerprintScanner.authenticate({ onAttempt: this.setError })
await this.setState({ isError: false })
setTimeout(this.goBack, 400)
}
} catch (err) {
this.setError(err)
}
}
errorCallback = err => err,
description,
androidError,
}) => {
const authConfig =
Platform.OS === 'ios'
? {
description:
description ||
'Scan your fingerprint on the device scanner to sign in',
}
: { onAttempt: androidError };
try {
await FingerprintScanner.isSensorAvailable();
try {
await FingerprintScanner.authenticate(authConfig);
successCallback();
} catch (error) {
errorCallback(error);
}
} catch (error) {
errorCallback(error);
}
};
componentDidMount() {
FingerprintScanner
.authenticate({ description: 'Scan your fingerprint on the device scanner to continue' })
.then(() => {
this.props.handlePopupDismissed();
AlertIOS.alert('Authenticated successfully');
})
.catch((error) => {
this.props.handlePopupDismissed();
AlertIOS.alert(error.message);
});
}
activateFingerPrintScanner() {
const { t } = this.props;
FingerprintScanner.authenticate({
onAttempt: this.handleAuthenticationAttempted,
description: t('instructions'),
})
.then(() => {
//this.props.generateAlert('success', 'Fingerprint authentication', 'Authenticated successfully');
this.setState({
currentFingerStatusInfo: 'Authenticated successfully',
currentFingerStatus: 1,
});
})
.catch(error => {
this.setState({ errorMessage: error.message });
});
}
handleAuthenticationAttempted = () => {
componentDidMount() {
FingerprintScanner
.authenticate({ onAttempt: this.handleAuthenticationAttempted })
.then(() => {
this.props.handlePopupDismissed();
Alert.alert('Fingerprint Authentication', 'Authenticated successfully');
})
.catch((error) => {
this.setState({ errorMessage: error.message });
this.description.shake();
});
}
activateFingerprintScanner() {
const { t } = this.props;
if (isAndroid) {
this.props.toggleModalActivity();
return timer.setTimeout('displayFingerPrintModal', () => this.showModal('fingerprint'), 300);
}
FingerprintScanner.authenticate({ description: t('fingerprintOnSend') })
.then(() => {
this.setSendingTransferFlag();
this.sendTransfer();
})
.catch(() => {
this.props.generateAlert(
'error',
t('fingerprintSetup:fingerprintAuthFailed'),
t('fingerprintSetup:fingerprintAuthFailedExplanation'),
);
});
}
deactivateFingerprintScanner() {
const { t } = this.props;
FingerprintScanner.authenticate({
description: t('instructionsDisable'),
})
.then(() => {
this.onSuccess();
})
.catch(() => {
this.onFailure();
});
}