Added support for app authorization in url auth box.

This commit is contained in:
23rd
2026-03-28 10:25:21 +03:00
parent 5907145fcc
commit e3f2e68947
4 changed files with 59 additions and 22 deletions
+2
View File
@@ -4760,6 +4760,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_url_auth_login_title" = "Log in to {domain}";
"lng_url_auth_login_button" = "Log in";
"lng_url_auth_site_access" = "This site will receive your **name**, **username** and **profile photo**.";
"lng_url_auth_app_access" = "This app will receive your **name**, **username** and **profile photo**.";
"lng_url_auth_unverified_app" = "Unverified App";
"lng_url_auth_device_label" = "Device";
"lng_url_auth_ip_label" = "IP Address";
"lng_url_auth_login_attempt" = "This login attempt came from the device above.";
+28 -7
View File
@@ -396,11 +396,16 @@ void RequestButton(
}).send();
}
};
const auto displayName = request.is_is_app()
? (request.vverified_app_name()
? qs(*request.vverified_app_name())
: tr::lng_url_auth_unverified_app(tr::now))
: qs(request.vdomain());
*box = show->show(
Box(
Show,
url,
qs(request.vdomain()),
displayName,
session->user()->name(),
bot->firstName,
callback),
@@ -425,7 +430,12 @@ void RequestUrl(
: nullptr;
const auto requestPhone = request.is_request_phone_number();
const auto matchCodesFirst = request.is_match_codes_first();
const auto domain = qs(request.vdomain());
const auto isApp = request.is_is_app();
const auto domain = isApp
? (request.vverified_app_name()
? qs(*request.vverified_app_name())
: tr::lng_url_auth_unverified_app(tr::now))
: qs(request.vdomain());
const auto userIdHint = request.vuser_id_hint()
? peerToUser(peerFromUser(*request.vuser_id_hint()))
: UserId();
@@ -495,6 +505,9 @@ void RequestUrl(
return url;
});
finishWithUrl(to, accepted);
const auto domainWrapped = isApp
? tr::bold(domain)
: tr::link(domain);
show->showToast(Ui::Toast::Config{
.title = tr::lng_url_auth_phone_toast_good_title(tr::now),
.text = ((requestPhone && !sharePhone)
@@ -502,17 +515,20 @@ void RequestUrl(
: tr::lng_url_auth_phone_toast_good)(
tr::now,
lt_domain,
tr::link(domain),
domainWrapped,
tr::marked),
.duration = crl::time(4000),
});
}).fail([=] {
const auto domainWrapped = isApp
? tr::bold(domain)
: tr::link(domain);
show->showToast(Ui::Toast::Config{
.title = tr::lng_url_auth_phone_toast_bad_title(tr::now),
.text = tr::lng_url_auth_phone_toast_bad(
tr::now,
lt_domain,
tr::link(domain),
domainWrapped,
tr::marked),
.duration = crl::time(4000),
});
@@ -585,7 +601,10 @@ void RequestUrl(
Ui::ConfirmBoxArgs{
.text = tr::lng_url_auth_phone_sure_text(
lt_domain,
rpl::single(tr::bold(capitalized(domain))),
rpl::single(
tr::bold(isApp
? domain
: capitalized(domain))),
lt_phone,
PhoneValue(currentSession->user()),
tr::rich),
@@ -618,7 +637,8 @@ void RequestUrl(
region,
(matchCodesFirst
? (rpl::single(QStringList()) | rpl::type_erased)
: matchCodesShared->value()));
: matchCodesShared->value()),
isApp);
*accountResult = AddAccountsMenu(
box->verticalLayout(),
@@ -669,7 +689,8 @@ void RequestUrl(
tr::now)
: error.type());
}).send();
});
},
isApp);
}),
Ui::LayerOption::KeepOther);
matchCodesBox->boxClosing() | rpl::on_next([=] {
@@ -50,7 +50,8 @@ void ShowMatchCodesBox(
Fn<std::shared_ptr<Ui::DynamicImage>(QString)> emojiImageFactory,
const QString &domain,
const QStringList &codes,
Fn<void(QString)> callback) {
Fn<void(QString)> callback,
bool isApp) {
box->setWidth(st::boxWidth);
box->setStyle(st::urlAuthBox);
@@ -175,8 +176,8 @@ void ShowMatchCodesBox(
Ui::AddSkip(content);
const auto domainUrl = qthelp::validate_url(domain);
if (!domainUrl.isEmpty()) {
const auto domainUrl = isApp ? QString() : qthelp::validate_url(domain);
if (!domainUrl.isEmpty() || isApp) {
Ui::AddSkip(content);
Ui::AddSkip(content);
content->add(
@@ -184,7 +185,9 @@ void ShowMatchCodesBox(
content,
tr::lng_url_auth_login_title(
lt_domain,
rpl::single(Ui::Text::Link(domain, domainUrl)),
rpl::single(isApp
? tr::bold(domain)
: Ui::Text::Link(domain, domainUrl)),
tr::marked),
st::urlAuthCheckboxAbout),
st::boxRowPadding,
@@ -433,7 +436,8 @@ void ShowDetails(
const QString &platform,
const QString &ip,
const QString &region,
rpl::producer<QStringList> matchCodes) {
rpl::producer<QStringList> matchCodes,
bool isApp) {
box->setWidth(st::boxWidth);
box->setStyle(st::urlAuthBox);
@@ -451,7 +455,7 @@ void ShowDetails(
Ui::AddSkip(content);
}
const auto domainUrl = qthelp::validate_url(domain);
const auto domainUrl = isApp ? QString() : qthelp::validate_url(domain);
const auto userpicButtonWidth = st::restoreUserpicIcon.photoSize;
const auto titlePadding = style::margins(
st::boxRowPadding.left(),
@@ -461,12 +465,17 @@ void ShowDetails(
content->add(
object_ptr<Ui::FlatLabel>(
content,
domainUrl.isEmpty()
? tr::lng_url_auth_login_button(tr::marked)
: tr::lng_url_auth_login_title(
(isApp
? tr::lng_url_auth_login_title(
lt_domain,
rpl::single(Ui::Text::Link(domain, domainUrl)),
tr::marked),
rpl::single(tr::bold(domain)),
tr::marked)
: domainUrl.isEmpty()
? tr::lng_url_auth_login_button(tr::marked)
: tr::lng_url_auth_login_title(
lt_domain,
rpl::single(Ui::Text::Link(domain, domainUrl)),
tr::marked)),
st::boxTitle),
titlePadding,
style::al_top);
@@ -475,7 +484,9 @@ void ShowDetails(
content->add(
object_ptr<Ui::FlatLabel>(
content,
tr::lng_url_auth_site_access(tr::rich),
(isApp
? tr::lng_url_auth_app_access(tr::rich)
: tr::lng_url_auth_site_access(tr::rich)),
st::urlAuthCheckboxAbout),
st::boxRowPadding);
@@ -564,7 +575,8 @@ void ShowDetails(
&& allowMessages->toggled()),
.matchCode = std::move(matchCode),
});
});
},
isApp);
}));
});
}
@@ -58,7 +58,8 @@ void ShowMatchCodesBox(
Fn<std::shared_ptr<Ui::DynamicImage>(QString)> emojiImageFactory,
const QString &domain,
const QStringList &codes,
Fn<void(QString)> callback);
Fn<void(QString)> callback,
bool isApp = false);
void Show(
not_null<Ui::GenericBox*> box,
@@ -80,6 +81,7 @@ void ShowDetails(
const QString &platform,
const QString &ip,
const QString &region,
rpl::producer<QStringList> matchCodes = rpl::single(QStringList()));
rpl::producer<QStringList> matchCodes = rpl::single(QStringList()),
bool isApp = false);
} // namespace UrlAuthBox