コード例 #1
0
        public async Task<IdentityResult> UpdateAsync(FantasyCriticUser user, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            user.SecurityStamp = Guid.NewGuid().ToString();
            user.UpdateLastUsedCredentials(_clock.GetCurrentInstant());
            await RemoveAllRefreshTokens(user);

            //Not updating password or email confirmed as that breaks password change. Use the SetPasswordHash.
            FantasyCriticUserEntity entity = new FantasyCriticUserEntity(user);
            string sql = $@"UPDATE tbluser SET UserName = @{nameof(FantasyCriticUserEntity.UserName)}, " +
                         $"NormalizedUserName = @{nameof(FantasyCriticUserEntity.NormalizedUserName)}, " +
                         $"EmailAddress = @{nameof(FantasyCriticUserEntity.EmailAddress)}, " +
                         $"NormalizedEmailAddress = @{nameof(FantasyCriticUserEntity.NormalizedEmailAddress)}, " +
                         $"PasswordHash = @{nameof(FantasyCriticUserEntity.PasswordHash)}, " +
                         $"EmailConfirmed = @{nameof(FantasyCriticUserEntity.EmailConfirmed)}, " +
                         $"SecurityStamp = @{nameof(FantasyCriticUserEntity.SecurityStamp)} " +
                         $"WHERE UserID = @{nameof(FantasyCriticUserEntity.UserID)}";

            using (var connection = new MySqlConnection(_connectionString))
            {
                await connection.OpenAsync(cancellationToken);
                await connection.ExecuteAsync(sql, entity);
            }

            return IdentityResult.Success;
        }
コード例 #2
0
    public async Task <IdentityResult> UpdateAsync(FantasyCriticUser user, CancellationToken cancellationToken)
    {
        cancellationToken.ThrowIfCancellationRequested();
        user.SecurityStamp = Guid.NewGuid().ToString();
        user.UpdateLastUsedCredentials(_clock.GetCurrentInstant());

        //Not updating password or email confirmed as that breaks password change. Use the SetPasswordHash.
        FantasyCriticUserEntity entity = new FantasyCriticUserEntity(user);
        string sql = $@"UPDATE tbl_user SET DisplayName = @{nameof(FantasyCriticUserEntity.DisplayName)}, " +
                     $"PatreonDonorNameOverride = @{nameof(FantasyCriticUserEntity.PatreonDonorNameOverride)}, " +
                     $"DisplayNumber = @{nameof(FantasyCriticUserEntity.DisplayNumber)}, " +
                     $"EmailAddress = @{nameof(FantasyCriticUserEntity.EmailAddress)}, " +
                     $"NormalizedEmailAddress = @{nameof(FantasyCriticUserEntity.NormalizedEmailAddress)}, " +
                     $"PasswordHash = @{nameof(FantasyCriticUserEntity.PasswordHash)}, " +
                     $"EmailConfirmed = @{nameof(FantasyCriticUserEntity.EmailConfirmed)}, " +
                     $"LastChangedCredentials = @{nameof(FantasyCriticUserEntity.LastChangedCredentials)}, " +
                     $"TwoFactorEnabled = @{nameof(FantasyCriticUserEntity.TwoFactorEnabled)}, " +
                     $"AuthenticatorKey = @{nameof(FantasyCriticUserEntity.AuthenticatorKey)}, " +
                     $"SecurityStamp = @{nameof(FantasyCriticUserEntity.SecurityStamp)} " +
                     $"WHERE UserID = @{nameof(FantasyCriticUserEntity.UserID)}";

        await using (var connection = new MySqlConnection(_connectionString))
        {
            await connection.OpenAsync(cancellationToken);

            await connection.ExecuteAsync(sql, entity);
        }

        _userCache = null;
        return(IdentityResult.Success);
    }