告诉我如何在安装 2FA 授权时链接邮件。 现在我收到错误 PASSWORD_HASH_INVALID
public async Task SetTwoAutorize()
{
try
{
// const string old_password = "password"; // current password if any (unused otherwise)
const string new_password = "new_pass"; // or null to disable 2FA
var accountPwd = await _Client.Account_GetPassword();
// var password = accountPwd.current_algo == null ? null : await Client.InputCheckPassword(accountPwd, old_password);
var password = accountPwd.current_algo == null ? null : await Client.InputCheckPassword(accountPwd, new_password);
accountPwd.current_algo = null; // makes InputCheckPassword generate a new password
var new_password_hash = new_password == null ? null : await Client.InputCheckPassword(accountPwd, new_password);
await _Client.Account_UpdatePasswordSettings(password, new Account_PasswordInputSettings
{
email = "my_email",
flags = Account_PasswordInputSettings.Flags.has_email,
new_password_hash = new_password_hash?.A,
new_algo = accountPwd.new_algo,
});
}
catch (Exception e)
{
string code = "";
await _Client.Account_ConfirmPasswordEmail(code);
}
}
我尝试遵循这种模式https://corefork.telegram.org/method/account.updatePasswordSettings但没有成功。
在通过邮件绑定创建2FA授权时,我使用了这段代码, 邮件确认码功能返回需要Account_Confirm密码Email方式
/// <summary>
/// Install 2FA authorization
/// </summary>
/// <param name="email"></param>
/// <param name="new_password">or null to disable 2FA</param>
/// <param name="Account_ConfirmPasswordEmail"></param>
/// <returns></returns>
public async Task SetTwoAutorize(string email, string new_password, Func<Task<string>> Account_ConfirmPasswordEmail)
{
try
{
// const string old_password = "password"; // current password if any (unused otherwise)
var accountPwd = await _Client.Account_GetPassword();
// var password = accountPwd.current_algo == null ? null : await Client.InputCheckPassword(accountPwd, old_password);
var _password = accountPwd.current_algo == null ? null : await Client.InputCheckPassword(accountPwd, new_password);
accountPwd.current_algo = null; // makes InputCheckPassword generate a new password
var new_password_hash = new_password == null ? null : await Client.InputCheckPassword(accountPwd, new_password);
await _Client.Account_UpdatePasswordSettings(_password, new Account_PasswordInputSettings
{
email = email,
flags = Account_PasswordInputSettings.Flags.has_new_algo | Account_PasswordInputSettings.Flags.has_email,
new_password_hash = new_password_hash?.A,
new_algo = accountPwd.new_algo
});
}
catch (Exception e)
{
var code = await Account_ConfirmPasswordEmail.Invoke(); //The code for confirming the mail
await _Client.Account_ConfirmPasswordEmail(code);
}
}