コード例 #1
0
        protected virtual async Task RemoveUserTokenAsync(IdentityUserToken token)
        {
            TUser user = await this.FindByIdAsync(token.UserId.ToString(), CancellationToken.None);

            List <IdentityUserToken> newList = new List <IdentityUserToken>(user.Tokens);

            newList.Remove(token);
            user.Tokens = newList;
        }
コード例 #2
0
        public virtual async Task SetTokenAsync(TUser user, String loginProvider, String name, String value, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            IdentityUserToken token = await this.FindTokenAsync(user, loginProvider, name, cancellationToken);

            if (token == null)
            {
                await this.AddUserTokenAsync(this.CreateUserToken(user, loginProvider, name, value));
            }
            else
            {
                token.Value = value;
            }
        }