Exemple #1
0
        public async Task <IEnumerable <TUser> > FindAllByNameAsync(string normalizedUserName,
                                                                    CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (SupportsSuperUser &&
                normalizedUserName == _lookupNormalizer.MaybeNormalizeName(_superUserInfoProvider?.Username))
            {
                return(new[] { CreateSuperUserInstance() });
            }

            var users = await _store.QueryByExampleAsync <TUser>(new { NormalizedUserName = normalizedUserName },
                                                                 cancellationToken);

            return(users.Data);
        }
Exemple #2
0
        public async Task <Operation <TRole> > CreateAsync(CreateRoleModel model)
        {
            var role = (TRole)FormatterServices.GetUninitializedObject(typeof(TRole));

            role.Name             = model.Name;
            role.ConcurrencyStamp = model.ConcurrencyStamp ?? $"{Guid.NewGuid()}";
            role.NormalizedName   = _lookupNormalizer.MaybeNormalizeName(model.Name);

            var result = await _roleManager.CreateAsync(role);

            return(result.ToOperation(role));
        }