Exemple #1
0
        /// <summary>
        ///     Generate a token for the user using their security stamp
        /// </summary>
        /// <param name="purpose"></param>
        /// <param name="manager"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public virtual async Task <string> GenerateAsync(string purpose, UserManager <TUser, TKey> manager, TUser user)
        {
            var token = await manager.CreateSecurityTokenAsync(user.Id).WithCurrentCulture();

            var modifier = await GetUserModifierAsync(purpose, manager, user).WithCurrentCulture();

            return(Rfc6238AuthenticationService.GenerateCode(token, modifier).ToString("D6", CultureInfo.InvariantCulture));
        }
        /// <summary>
        ///     Generate a token for the user using their security stamp
        /// </summary>
        /// <param name="purpose"></param>
        /// <param name="manager"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public virtual async Task <string> GenerateAsync(string purpose, UserManager <TUser> manager, TUser user)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }
            var token = await manager.CreateSecurityTokenAsync(user);

            var modifier = await GetUserModifierAsync(purpose, manager, user);

            return(Rfc6238AuthenticationService.GenerateCode(token, modifier).ToString("D6", CultureInfo.InvariantCulture));
        }