TotpSecurityStampBasedTokenProvider<TUser>.GenerateAsync Method

Definition

Generates a token for the specified user and purpose.

public:
 virtual System::Threading::Tasks::Task<System::String ^> ^ GenerateAsync(System::String ^ purpose, Microsoft::AspNetCore::Identity::UserManager<TUser> ^ manager, TUser user);
public virtual System.Threading.Tasks.Task<string> GenerateAsync (string purpose, Microsoft.AspNetCore.Identity.UserManager<TUser> manager, TUser user);
abstract member GenerateAsync : string * Microsoft.AspNetCore.Identity.UserManager<'User (requires 'User : null)> * 'User -> System.Threading.Tasks.Task<string>
override this.GenerateAsync : string * Microsoft.AspNetCore.Identity.UserManager<'User (requires 'User : null)> * 'User -> System.Threading.Tasks.Task<string>
Public Overridable Function GenerateAsync (purpose As String, manager As UserManager(Of TUser), user As TUser) As Task(Of String)

Parameters

purpose
String

The purpose the token will be used for.

manager
UserManager<TUser>

The UserManager<TUser> that can be used to retrieve user properties.

user
TUser

The user a token should be generated for.

Returns

The Task that represents the asynchronous operation, containing the token for the specified user and purpose.

Implements

Remarks

The purpose parameter allows a token generator to be used for multiple types of token whilst insuring a token for one purpose cannot be used for another. For example if you specified a purpose of "Email" and validated it with the same purpose a token with the purpose of TOTP would not pass the check even if it was for the same user.

Implementations of IUserTwoFactorTokenProvider<TUser> should validate that purpose is not null or empty to help with token separation.

Applies to