public async Task <string> CreateLoginAsync(OAuthUserItem item) { if (item == null) { return(null); } if (await _context.OAuthUserEntityCollection.CountAsync(x => x.Email == item.Email) == 0) { ObjectId id = ObjectId.GenerateNewId(); item.Claims.Add(new Claim("sub", id.ToString())); OAuthUserEntity user = new OAuthUserEntity() { Id = id, Email = item.Email, EmailVerified = item.EmailVerified, Password = item.Password, Salt = item.Salt, Providers = item.Providers, IsActive = item.IsActive, Roles = item.Roles, Claims = item.Claims }; await _context.OAuthUserEntityCollection.InsertOneAsync(user); return(user.Id.ToString()); } return(null); }
public async Task <OAuthUserEntity> FindByEmailAsync(string email) { OAuthUserEntity user = await _context.OAuthUserEntityCollection.Find(x => x.Email == email.ToLower()) //.Project<OAuthUserEntity>(Builders<OAuthUserEntity>.Projection // .Exclude(x => x.CreatedBy)) .FirstOrDefaultAsync(); return(user); }