2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Allow saving and using saved credentials.

This commit is contained in:
John Preston
2021-03-31 21:15:49 +04:00
parent 2e58993181
commit 663db64688
16 changed files with 350 additions and 55 deletions

View File

@@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_lock_widgets.h"
#include "window/themes/window_theme.h"
//#include "platform/platform_specific.h"
#include "base/unixtime.h"
#include "calls/calls_instance.h"
#include "support/support_helper.h"
#include "facades.h"
@@ -43,6 +44,7 @@ namespace Main {
namespace {
constexpr auto kLegacyCallsPeerToPeerNobody = 4;
constexpr auto kTmpPasswordReserveTime = TimeId(10);
[[nodiscard]] QString ValidatedInternalLinksDomain(
not_null<const Session*> session) {
@@ -155,6 +157,20 @@ Session::Session(
_api->requestNotifySettings(MTP_inputNotifyBroadcasts());
}
void Session::setTmpPassword(const QByteArray &password, TimeId validUntil) {
if (_tmpPassword.isEmpty() || validUntil > _tmpPasswordValidUntil) {
_tmpPassword = password;
_tmpPasswordValidUntil = validUntil;
}
}
QByteArray Session::validTmpPassword() const {
return (_tmpPasswordValidUntil
>= base::unixtime::now() + kTmpPasswordReserveTime)
? _tmpPassword
: QByteArray();
}
// Can be called only right before ~Session.
void Session::finishLogout() {
updates().updateOnline();