Added ability to set recovery email from cloud password management.
This commit is contained in:
		
							parent
							
								
									a72953411b
								
							
						
					
					
						commit
						3e4ac35913
					
				
					 3 changed files with 34 additions and 14 deletions
				
			
		|  | @ -32,6 +32,7 @@ struct StepData { | ||||||
| 	QString hint; | 	QString hint; | ||||||
| 	QString email; | 	QString email; | ||||||
| 	int unconfirmedEmailLengthCode; | 	int unconfirmedEmailLengthCode; | ||||||
|  | 	bool setOnlyRecoveryEmail = false; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| void SetupHeader( | void SetupHeader( | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | ||||||
| #include "settings/cloud_password/settings_cloud_password_email.h" | #include "settings/cloud_password/settings_cloud_password_email.h" | ||||||
| 
 | 
 | ||||||
| #include "api/api_cloud_password.h" | #include "api/api_cloud_password.h" | ||||||
|  | #include "core/core_cloud_password.h" | ||||||
| #include "lang/lang_keys.h" | #include "lang/lang_keys.h" | ||||||
| #include "settings/cloud_password/settings_cloud_password_common.h" | #include "settings/cloud_password/settings_cloud_password_common.h" | ||||||
| #include "settings/cloud_password/settings_cloud_password_email_confirm.h" | #include "settings/cloud_password/settings_cloud_password_email_confirm.h" | ||||||
|  | @ -45,13 +46,19 @@ void Email::setupContent() { | ||||||
| 	const auto content = Ui::CreateChild<Ui::VerticalLayout>(this); | 	const auto content = Ui::CreateChild<Ui::VerticalLayout>(this); | ||||||
| 	auto currentStepData = stepData(); | 	auto currentStepData = stepData(); | ||||||
| 	const auto currentStepDataEmail = base::take(currentStepData.email); | 	const auto currentStepDataEmail = base::take(currentStepData.email); | ||||||
|  | 	const auto setOnly = base::take(currentStepData.setOnlyRecoveryEmail); | ||||||
| 	setStepData(currentStepData); | 	setStepData(currentStepData); | ||||||
| 
 | 
 | ||||||
|  | 	const auto state = cloudPassword().stateCurrent(); | ||||||
|  | 	const auto hasRecovery = state && state->hasRecovery; | ||||||
|  | 
 | ||||||
| 	SetupHeader( | 	SetupHeader( | ||||||
| 		content, | 		content, | ||||||
| 		u"cloud_password/email"_q, | 		u"cloud_password/email"_q, | ||||||
| 		showFinishes(), | 		showFinishes(), | ||||||
| 		tr::lng_settings_cloud_password_email_subtitle(), | 		hasRecovery | ||||||
|  | 			? tr::lng_settings_cloud_password_manage_email_change() | ||||||
|  | 			: tr::lng_settings_cloud_password_email_subtitle(), | ||||||
| 		tr::lng_settings_cloud_password_email_about()); | 		tr::lng_settings_cloud_password_email_about()); | ||||||
| 
 | 
 | ||||||
| 	AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip); | 	AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip); | ||||||
|  | @ -69,12 +76,14 @@ void Email::setupContent() { | ||||||
| 
 | 
 | ||||||
| 		const auto data = stepData(); | 		const auto data = stepData(); | ||||||
| 
 | 
 | ||||||
| 		_requestLifetime = cloudPassword().set( | 		_requestLifetime = (setOnly | ||||||
|  | 			? cloudPassword().setEmail(data.currentPassword, data.email) | ||||||
|  | 			: cloudPassword().set( | ||||||
| 				data.currentPassword, | 				data.currentPassword, | ||||||
| 				data.password, | 				data.password, | ||||||
| 				data.hint, | 				data.hint, | ||||||
| 				!data.email.isEmpty(), | 				!data.email.isEmpty(), | ||||||
| 			data.email | 				data.email) | ||||||
| 		) | rpl::start_with_next_error_done([=](Api::CloudPassword::SetOk d) { | 		) | rpl::start_with_next_error_done([=](Api::CloudPassword::SetOk d) { | ||||||
| 			_requestLifetime.destroy(); | 			_requestLifetime.destroy(); | ||||||
| 
 | 
 | ||||||
|  | @ -134,6 +143,7 @@ void Email::setupContent() { | ||||||
| 	skip->setClickedCallback([=] { | 	skip->setClickedCallback([=] { | ||||||
| 		confirm(QString()); | 		confirm(QString()); | ||||||
| 	}); | 	}); | ||||||
|  | 	skip->setVisible(!setOnly); | ||||||
| 
 | 
 | ||||||
| 	const auto button = AddDoneButton( | 	const auto button = AddDoneButton( | ||||||
| 		content, | 		content, | ||||||
|  |  | ||||||
|  | @ -130,6 +130,16 @@ void Manage::setupContent() { | ||||||
| 		} | 		} | ||||||
| 	}, lifetime()); | 	}, lifetime()); | ||||||
| 
 | 
 | ||||||
|  | 	const auto showOtherAndRememberPassword = [=](Type type) { | ||||||
|  | 		// Remember the current password to have ability
 | ||||||
|  | 		// to return from Change Password to Password Manage.
 | ||||||
|  | 		auto data = stepData(); | ||||||
|  | 		data.currentPassword = _currentPassword; | ||||||
|  | 		setStepData(std::move(data)); | ||||||
|  | 
 | ||||||
|  | 		showOther(type); | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
| 	SetupTopContent(content, showFinishes()); | 	SetupTopContent(content, showFinishes()); | ||||||
| 
 | 
 | ||||||
| 	AddSkip(content); | 	AddSkip(content); | ||||||
|  | @ -139,13 +149,7 @@ void Manage::setupContent() { | ||||||
| 		st::settingsButton, | 		st::settingsButton, | ||||||
| 		{ &st::settingsIconKey, kIconLightBlue } | 		{ &st::settingsIconKey, kIconLightBlue } | ||||||
| 	)->setClickedCallback([=] { | 	)->setClickedCallback([=] { | ||||||
| 		// Remember the current password to have ability
 | 		showOtherAndRememberPassword(CloudPasswordInputId()); | ||||||
| 		// to return from Change Password to Password Manage.
 |  | ||||||
| 		auto data = stepData(); |  | ||||||
| 		data.currentPassword = _currentPassword; |  | ||||||
| 		setStepData(std::move(data)); |  | ||||||
| 
 |  | ||||||
| 		showOther(CloudPasswordInputId()); |  | ||||||
| 	}); | 	}); | ||||||
| 	AddButton( | 	AddButton( | ||||||
| 		content, | 		content, | ||||||
|  | @ -155,6 +159,11 @@ void Manage::setupContent() { | ||||||
| 		st::settingsButton, | 		st::settingsButton, | ||||||
| 		{ &st::settingsIconEmail, kIconLightOrange } | 		{ &st::settingsIconEmail, kIconLightOrange } | ||||||
| 	)->setClickedCallback([=] { | 	)->setClickedCallback([=] { | ||||||
|  | 		auto data = stepData(); | ||||||
|  | 		data.setOnlyRecoveryEmail = true; | ||||||
|  | 		setStepData(std::move(data)); | ||||||
|  | 
 | ||||||
|  | 		showOtherAndRememberPassword(CloudPasswordEmailId()); | ||||||
| 	}); | 	}); | ||||||
| 	AddSkip(content); | 	AddSkip(content); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 23rd
						23rd