コード例 #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);
    }
コード例 #3
0
        public async Task<IdentityResult> CreateAsync(FantasyCriticUser user, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            FantasyCriticUserEntity entity = new FantasyCriticUserEntity(user);
            using (var connection = new MySqlConnection(_connectionString))
            {
                await connection.OpenAsync(cancellationToken);
                await connection.ExecuteAsync(
                    "insert into tbluser(UserID,UserName,NormalizedUserName,EmailAddress,NormalizedEmailAddress,PasswordHash,SecurityStamp,LastChangedCredentials,EmailConfirmed) VALUES " +
                    "(@UserID,@UserName,@NormalizedUserName,@EmailAddress,@NormalizedEmailAddress,@PasswordHash,@SecurityStamp,@LastChangedCredentials,@EmailConfirmed)",
                    entity);
            }

            return IdentityResult.Success;
        }
コード例 #4
0
    public async Task <IdentityResult> CreateAsync(FantasyCriticUser user, CancellationToken cancellationToken)
    {
        cancellationToken.ThrowIfCancellationRequested();

        FantasyCriticUserEntity entity = new FantasyCriticUserEntity(user);

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

            await connection.ExecuteAsync(
                "insert into tbl_user(UserID,DisplayName,PatreonDonorNameOverride,DisplayNumber,EmailAddress,NormalizedEmailAddress,PasswordHash,SecurityStamp," +
                "TwoFactorEnabled,AuthenticatorKey,LastChangedCredentials,EmailConfirmed,IsDeleted) VALUES " +
                "(@UserID,@DisplayName,@PatreonDonorNameOverride,@DisplayNumber,@EmailAddress,@NormalizedEmailAddress,@PasswordHash,@SecurityStamp," +
                "@TwoFactorEnabled,@AuthenticatorKey,@LastChangedCredentials,@EmailConfirmed,@IsDeleted)",
                entity);
        }

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