我无法弄清楚如何在asp.net核心1.1中进行电话号码确认
身份服务配置包含要求确认的电子邮件和/或电话号码的明确选项.
它可以通过以下方式完成:
services
.AddIdentity<User, Role>(options =>
{
options.SignIn.RequireConfirmedEmail = true;
options.SignIn.RequireConfirmedPhoneNumber = true;
});
Run Code Online (Sandbox Code Playgroud)
由于UserManager包含显式令牌生成器及其验证器,因此电子邮件的验证非常简单:
var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
Run Code Online (Sandbox Code Playgroud)
生成的令牌可以通过以下方式验证:
var result = await _userManager.ConfirmEmailAsync(user, code);
Run Code Online (Sandbox Code Playgroud)
如果令牌有效,上面的行将把user.EmailConfirmed标志切换为true.
现在的问题是我没有看到类似的方法来生成电话验证令牌及其等效方法来验证它(如果成功,它应该将user.PhoneNumberConfirmed标志切换为true).
但是,用户管理器包含的用户手机更改方法很少:
_userManager.GenerateChangePhoneNumberTokenAsync();
Run Code Online (Sandbox Code Playgroud)
和
_userManager.VerifyChangePhoneNumberTokenAsync();
Run Code Online (Sandbox Code Playgroud)
但似乎这些方法不会切换user.PhoneNumberConfirmed标志.
我错过了什么吗?确认用户电话号码的正确方法是什么(换句话说,将user.PhoneNumberConfirmed设置为true)?
我正在尝试配置数据保护并使用证书来保护密钥文件.以下是MS文档配置数据保护
这是我正在尝试做的事情:
services
.AddDataProtection()
.SetApplicationName("test server")
.PersistKeysToFileSystem("/home/www-data/config")
.ProtectKeysWithCertificate(
new X509Certificate2("/home/www-data/config/"keyprotection.pfx);
Run Code Online (Sandbox Code Playgroud)
当我启动应用程序时,我在启动时收到以下错误:
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
Creating key {71e2c23f-448b-49c9-984f-3c8d7227c904} with
creation date 2017-08-29 18:53:51Z, activation date 2017-08-29 18:53:51Z, and expiration date 2017-11-27 18:53:51Z.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
Writing data to file '/home/www-data/config/key-71e2c23f-448b-49c9-984f-3c8d7227c904.xml'.
fail: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[24]
An exception occurred while processing the key element '<key id="71e2c23f-448b-49c9-984f-3c8d7227c904" version="1" />'.
System.Security.Cryptography.CryptographicException: Unable to retrieve the decryption key.
at System.Security.Cryptography.Xml.EncryptedXml.GetDecryptionKey(EncryptedData encryptedData, String symmetricAlgorithmUri)
at System.Security.Cryptography.Xml.EncryptedXml.DecryptDocument()
at Microsoft.AspNetCore.DataProtection.XmlEncryption.EncryptedXmlDecryptor.Decrypt(XElement encryptedElement)
at Microsoft.AspNetCore.DataProtection.XmlEncryption.XmlEncryptionExtensions.DecryptElement(XElement element, IActivator activator)
at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.IInternalXmlKeyManager.DeserializeDescriptorFromKeyElement(XElement keyElement)
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.DefaultKeyResolver[12]
Key …Run Code Online (Sandbox Code Playgroud) 我知道我可以std::future通过以下方式检查状态:
my_future.wait_for(std::chrono::seconds(0)) == std::future_status::ready
但是根据cppreference.com, std::future::wait_for在某些情况下可能会阻止:
由于调度或资源争用延迟,此功能可能阻塞的时间超过timeout_duration。
还是timeout_duration0 还是这样吗?如果是这样,是否还有另一种以保证免等待的方式查询状态的方法?
我有一个带有 autotools 项目的第三方库。我想使用 ExternalProject_Add 来构建库。
这可以通过以下方式完成:
ExternalProject_Add(project_lib
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/configure --prefix=${LIB_OUTPUT}
BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build
)
Run Code Online (Sandbox Code Playgroud)
现在的问题是我需要将环境变量传递给,configure但我找不到方法来做到这一点。
在控制台中,我会按照以下方式进行:
CPPFLAGS="-fPIC" ./configure --prefix=output
有没有办法将CPPFLAGS="-fPIC"env传递给configurewith ExternalProject_Add/CONFIGURE_COMMAND?
考虑以下代码:
class Test
{
public:
Test()
{
}
Test(const Test &other) noexcept
{
*this = other;
}
Test(Test &&other) noexcept
{
*this = std::move(other);
}
auto operator = (const Test &other) noexcept -> Test&
{
// Make a copy of "other"
// ...
return *this;
}
auto operator = (Test &&other) noexcept -> Test&
{
// Move "other"
// ...
return *this;
}
};
Run Code Online (Sandbox Code Playgroud)
我想将移动和复制构造函数组合在一起。据我所知,可以像这样使用 std::forward 来实现:
template <class T>
Test(T &&other) noexcept
{
*this = std::forward<T>(other);
}
Run Code Online (Sandbox Code Playgroud)
如果仔细使用,它看起来运行良好,如下所示:
Test …Run Code Online (Sandbox Code Playgroud) 我使用 JetBrains Rider 进行 C# 编程。通常,Rider 会在我的代码中强调一些操作,例如以下list.WhereLINQ 方法调用:
当我将鼠标光标放在Where关键字上时,它会显示以下消息:
编译不会生成任何警告,Rider 本身也不会显示任何警告。但那又是什么意思呢?