コード例 #1
0
 public override async Task AddLoginAsync(ApplicationUser <TKey> user, UserLoginInfo login, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     ThrowIfDisposed();
     user.ThrowIfNull(nameof(user));
     login.ThrowIfNull(nameof(login));
     UserLogins ??= (await UserLoginsTable.GetLoginsAsync(user.Id)).ToList();
     UserLogins.Add(CreateUserLogin(user, login));
 }
コード例 #2
0
        public async Task AddLoginAsync(T user, UserLoginInfo login)
        {
            user.ThrowIfNull("user");
            login.ThrowIfNull("login");

            _log.DebugFormat("Adding external login: {0}, {1}", login.LoginProvider, login.ProviderKey);
            user.AddExternalLogin(login);
            await UpdateAsync(user);
            await CreateExternalLoginIndex(user, login);
        }
コード例 #3
0
        public async Task RemoveLoginAsync(T user, UserLoginInfo login)
        {
            user.ThrowIfNull("user");
            login.ThrowIfNull("login");

            _log.DebugFormat("Removing external login: {0}, {1}", login.LoginProvider, login.ProviderKey);
            user.RemoveExternalLogin(login);
            await UpdateAsync(user);

            await _identityTables.DeleteUserExternalLoginIndexTableEntity(new UserExternalLoginIndex(login));
        }
コード例 #4
0
        public async Task <T> FindAsync(UserLoginInfo login)
        {
            login.ThrowIfNull("login");

            _log.DebugFormat("Finding user by external login: {0}, {1}", login.LoginProvider, login.ProviderKey);
            var indexItem = new UserExternalLoginIndex(login);
            var index     = await _identityTables.RetrieveUserExternalLoginIndexAsync(indexItem);

            _log.DebugFormat("REsult of finding user by external login: {0}", index);
            return(index == null
                ? null
                : await FindByIdAsync(index.UserId));
        }
コード例 #5
0
        public async Task AddLoginAsync(ApplicationUser user, UserLoginInfo login, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();
            user.ThrowIfNull(nameof(user));
            login.ThrowIfNull(nameof(login));
            user.Logins ??= (await GetLoginsAsync(user, cancellationToken)).ToList();
            var foundLogin = user.Logins.SingleOrDefault(x => x.LoginProvider == login.LoginProvider && x.ProviderKey == login.ProviderKey);

            if (foundLogin == null)
            {
                user.Logins.Add(login);
            }
        }