mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-23 12:08:53 +00:00
feat: detect if biometrics was enabled
This commit is contained in:
parent
1f0d65ada5
commit
dcdb910f4f
@ -14,7 +14,7 @@ class Keychain : public QObject {
|
|||||||
|
|
||||||
Q_PROPERTY(QString service READ service WRITE setService NOTIFY serviceChanged)
|
Q_PROPERTY(QString service READ service WRITE setService NOTIFY serviceChanged)
|
||||||
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
|
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
|
||||||
Q_PROPERTY(bool available READ available CONSTANT)
|
Q_PROPERTY(bool available READ available NOTIFY availableChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Keychain(QObject *parent = nullptr);
|
explicit Keychain(QObject *parent = nullptr);
|
||||||
@ -50,6 +50,7 @@ signals:
|
|||||||
void serviceChanged();
|
void serviceChanged();
|
||||||
void reasonChanged();
|
void reasonChanged();
|
||||||
void loadingChanged();
|
void loadingChanged();
|
||||||
|
void availableChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_service;
|
QString m_service;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
@ -50,6 +51,15 @@ Keychain::Keychain(QObject *parent)
|
|||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
reevaluateAvailability();
|
reevaluateAvailability();
|
||||||
|
|
||||||
|
connect(qApp,
|
||||||
|
&QGuiApplication::applicationStateChanged,
|
||||||
|
this,
|
||||||
|
[this](Qt::ApplicationState state) {
|
||||||
|
if (state == Qt::ApplicationActive) {
|
||||||
|
reevaluateAvailability();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Keychain::~Keychain()
|
Keychain::~Keychain()
|
||||||
@ -213,12 +223,17 @@ void Keychain::reevaluateAvailability()
|
|||||||
auto context = [[LAContext alloc] init];
|
auto context = [[LAContext alloc] init];
|
||||||
NSError *authError = nil;
|
NSError *authError = nil;
|
||||||
|
|
||||||
m_available = [context canEvaluatePolicy:authPolicy error:&authError];
|
const auto available = [context canEvaluatePolicy:authPolicy error:&authError];
|
||||||
|
|
||||||
if (!m_available) {
|
// Later this description can be used if needed:
|
||||||
const auto description = QString::fromNSString(authError.localizedDescription);
|
// const auto description = QString::fromNSString(authError.localizedDescription);
|
||||||
qDebug() << "Keychain is not available" << description;
|
|
||||||
|
if (m_available == available) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_available = available;
|
||||||
|
emit availableChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
Keychain::Status Keychain::hasCredential(const QString &account) const
|
Keychain::Status Keychain::hasCredential(const QString &account) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user