PasswordSignInAsync of SignInManager
PasswordSignInAsync
/// <summary>
/// Attempts to sign in the specified <paramref name="userName"/> and <paramref name="password"/> combination
/// as an asynchronous operation.
/// </summary>
/// <param name="userName">The user name to sign in.</param>
/// <param name="password">The password to attempt to sign in with.</param>
/// <param name="isPersistent">Flag indicating whether the sign-in cookie should persist after the browser is closed.</param>
/// <param name="lockoutOnFailure">Flag indicating if the user account should be locked if the sign in fails.</param>
/// <returns>The task object representing the asynchronous operation containing the <see name="SignInResult"/>
/// for the sign-in attempt.</returns>
public virtual async Task<SignInResult> PasswordSignInAsync(string userName, string password,
bool isPersistent, bool lockoutOnFailure)
{
var user = await UserManager.FindByNameAsync(userName);
if (user == null)
{
return SignInResult.Failed;
}
return await PasswordSignInAsync(user, password, isPersistent, lockoutOnFailure);
}
https://github.com/dotnet/aspnetcore/blob/main/src/Identity/Extensions.Core/src/UserManager.cs#L528
/// <summary>
/// Finds and returns a user, if any, who has the specified user name.
/// </summary>
/// <param name="userName">The user name to search for.</param>
/// <returns>
/// The <see cref="Task"/> that represents the asynchronous operation, containing the user matching the specified <paramref name="userName"/> if it exists.
/// </returns>
public virtual async Task<TUser?> FindByNameAsync(string userName)
{
ThrowIfDisposed();
ArgumentNullThrowHelper.ThrowIfNull(userName);
userName = NormalizeName(userName);
var user = await Store.FindByNameAsync(userName, CancellationToken).ConfigureAwait(false);
// Need to potentially check all keys
if (user == null && Options.Stores.ProtectPersonalData)
{
var keyRing = _services.GetService<ILookupProtectorKeyRing>();
var protector = _services.GetService<ILookupProtector>();
if (keyRing != null && protector != null)
{
foreach (var key in keyRing.GetAllKeyIds())
{
var oldKey = protector.Protect(key, userName);
user = await Store.FindByNameAsync(oldKey, CancellationToken).ConfigureAwait(false);
if (user != null)
{
return user;
}
}
}
}
return user;
}
Can not decode the source ocde of Microsoft.AspNetCore.Identity.dll version 6.0.16 · Issue #216 · dnSpyEx/dnSpy · GitHub
Describe the Bug
The source code decode does not work for C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\6.0.16\ref\net6.0\Microsoft.AspNetCore.Identity.dll, the corresponding nuget library is https://www.nuget.org/packages/Microsoft.AspNetCore.App.Ref/6.0.16
public class SignInManager where TUser : class
The method body for PasswordSignInAsync is throw null
解答:
Here is the answer from GPT-4:
The "Ref" refers to "Reference" in the filename Microsoft.AspNetCore.App.Ref.dll
.
Microsoft.AspNetCore.App.Ref.dll
is part of the .NET Core shared framework and includes reference assemblies, or assemblies that contain just metadata of the types in the package and no actual implementation.
These reference assemblies are used at compile time for type resolution, so the compiler can confirm that the used .NET APIs are valid and types can be resolved. At runtime, an application uses the actual runtime assemblies found in the shared framework, not these reference assemblies.
Hint: compare your dll with the one located at C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\6.0.16\Microsoft.AspNetCore.Identity.dll
it works when I load the assembly from the shared folder, tick the "decompile async methods" is required
and the code maps to https://github.com/dotnet/aspnetcore/releases/tag/v6.0.16 on commit d6f154cca3863703cf87c8b840eea9cbe20229b2
https://github.com/dotnet/aspnetcore/blob/d6f154cca3863703cf87c8b840eea9cbe20229b2/src/Identity/Core/src/SignInManager.cs#L330
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2022-07-03 C# Async Tips and Tricks Part 2 : Async Void
2022-07-03 Error `Async test method must have non-void return type` when upgrading from NUnit 2 to NUnit 3
2022-07-03 Are Windows file timestamps timezone aware?
2022-07-03 Navigate To Decompiled Sources Resharper
2022-07-03 How to: View and edit code by using Peek Definition (Alt+F12)
2022-07-03 炉石传说 佣兵战纪 PvE克制
2022-07-03 Redmi红米 设置Sim卡PIN码