Skip to content

Commit

Permalink
Version 5.2.1: No auto-enable system password unlock on macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jul 1, 2024
1 parent 096530c commit dc8c4a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/main/main_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ bool Domain::removePasscodeIfEmpty() {
return false;
}
_local->setPasscode(QByteArray());
Core::App().settings().setSystemUnlockEnabled(false);
Core::App().saveSettingsDelayed();
return true;
}

Expand Down
16 changes: 14 additions & 2 deletions Telegram/SourceFiles/settings/settings_local_passcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class LocalPasscodeEnter : public AbstractSection {
rpl::event_stream<> _setInnerFocus;
rpl::event_stream<Type> _showOther;
rpl::event_stream<> _showBack;
bool _systemUnlockWithBiometric = false;

};

Expand All @@ -97,6 +98,13 @@ rpl::producer<QString> LocalPasscodeEnter::title() {
void LocalPasscodeEnter::setupContent() {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);

base::SystemUnlockStatus(
true
) | rpl::start_with_next([=](base::SystemUnlockAvailability status) {
_systemUnlockWithBiometric = status.available
&& status.withBiometrics;
}, lifetime());

const auto isCreate = (enterType() == EnterType::Create);
const auto isCheck = (enterType() == EnterType::Check);
[[maybe_unused]] const auto isChange = (enterType() == EnterType::Change);
Expand Down Expand Up @@ -242,8 +250,10 @@ void LocalPasscodeEnter::setupContent() {
}
SetPasscode(_controller, newText);
if (isCreate) {
Core::App().settings().setSystemUnlockEnabled(true);
Core::App().saveSettingsDelayed();
if (Platform::IsWindows() || _systemUnlockWithBiometric) {
Core::App().settings().setSystemUnlockEnabled(true);
Core::App().saveSettingsDelayed();
}
_showOther.fire(LocalPasscodeManageId());
} else if (isChange) {
_showBack.fire({});
Expand Down Expand Up @@ -601,6 +611,8 @@ QPointer<Ui::RpWidget> LocalPasscodeManage::createPinnedToBottom(
.text = tr::lng_settings_passcode_disable_sure(),
.confirmed = [=](Fn<void()> &&close) {
SetPasscode(_controller, QString());
Core::App().settings().setSystemUnlockEnabled(false);
Core::App().saveSettingsDelayed();

close();
_showBack.fire({});
Expand Down

0 comments on commit dc8c4a8

Please sign in to comment.