Exemplo n.º 1
0
        //IUserLoginStore
        public virtual Task AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken)
        {
            MongoDbUserLogin item = new MongoDbUserLogin();

            item.UserId              = user.Id;
            item.LoginProvider       = login.LoginProvider;
            item.ProviderKey         = login.ProviderKey;
            item.ProviderDisplayName = login.ProviderDisplayName;

            return(_context.UserLogins.InsertOneAsync(item, null, cancellationToken));
        }
Exemplo n.º 2
0
        public virtual async Task <TUser> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken)
        {
            FilterDefinition <MongoDbUserLogin> filter = Builders <MongoDbUserLogin> .Filter.Where(
                p => p.LoginProvider == loginProvider &&
                p.ProviderKey == providerKey);

            IAsyncCursor <MongoDbUserLogin> cursor = await _context.UserLogins.FindAsync(filter, null, cancellationToken);

            MongoDbUserLogin userLogin = await cursor.FirstOrDefaultAsync(cancellationToken);

            if (userLogin == null)
            {
                return(null);
            }

            return(await FindByIdAsync(userLogin.UserId.ToString(), cancellationToken));
        }