示例#1
0
        public Task <AdminUser> AddAdminUser(AdminUser adminUser)
        {
            var adminUserExist = _adminUserRepository.GetByEmail(adminUser.Email).Result;

            if (adminUserExist != null)
            {
                throw new ArgumentException(string.Format("User with Email {0} already used", adminUser.Email), "email");
            }

            _adminUserRepository.Add(adminUser);
            var saved = _adminUserRepository.SaveChangesAsync().Result;

            if (!saved)
            {
                return(null);
            }

            return(_adminUserRepository.Get(adminUser.Id));
        }
示例#2
0
        public IEnumerable <AdminRole> GetAdminRoles(string adminUserId)
        {
            var adminUser = _adminUserRepository.Get(adminUserId, "AdminUserRoles.AdminRole").Result;

            if (adminUser == null)
            {
                return(new List <AdminRole>());
            }

            return(adminUser.AdminUserRoles.Select(a => a.AdminRole));
        }
示例#3
0
        public Task GetProfileDataAsync(ProfileDataRequestContext context)
        {
            var adminUser = _AdminUserRepository.Get(context.Subject.GetSubjectId(),
                                                     "AdminUserRoles.AdminUser").Result;

            context.IssuedClaims.Add(new Claim("email", adminUser.Email));
            context.IssuedClaims.Add(new Claim("firstName", adminUser.FirstName));
            context.IssuedClaims.Add(new Claim("lastName", adminUser.LastName));

            if (adminUser.AdminUserRoles.Where(u => u.AdminRoleId == 0).Count() > 0)
            {
                context.IssuedClaims.Add(new Claim("role", "SuperAdmin"));
            }
            //if (context.RequestedClaimTypes.Any())
            //{
            //    context.IssuedClaims.Add(new Claim("role", "superAdmin"));
            //    context.IssuedClaims.Add(new Claim("role", "clientAdmin"));
            //    context.IssuedClaims.Add(new Claim("role", "userAdmin"));
            //}

            return(Task.FromResult(0));
        }