Ejemplo n.º 1
0
        private async Task SeedGlobalAdministrator(
            ICredentialRoleStore credentialRoleStore,
            ICredentialStore credentialStore)
        {
            bool isExistingAnyAdminCredentials =
                await credentialStore.IsExistingByCredentialRoleCode(SentinelCredentialRoleCodes.GlobalAdmin);

            if (!isExistingAnyAdminCredentials)
            {
                string adminCredentialId = SentinelCredentialIds.Admin;

                CredentialRole adminRole =
                    await credentialRoleStore.Get(SentinelCredentialRoleCodes.GlobalAdmin);

                Credential admin = new Credential();
                admin.BirthDate    = new DateTime(2000, 1, 1);
                admin.CreationDate = DateTime.UtcNow;
                admin.DisplayName  = adminCredentialId;
                admin.CredentialId = adminCredentialId;
                admin.Email        = adminCredentialId + "@admin.com";
                admin.PasswordSalt = HashingUtil.GenerateSalt();
                admin.PasswordHash = HashingUtil.GenerateHash(adminCredentialId, admin.PasswordSalt);
                admin.Roles        = new List <CredentialRole> {
                    adminRole
                };

                await credentialStore.Create(admin);
            }
        }
Ejemplo n.º 2
0
        public async Task Update(CredentialRole credentialRole)
        {
            var found = Roles.FirstOrDefault(x => x.Code == credentialRole.Code);

            if (found != null)
            {
                found.Description = credentialRole.Description;
            }
        }
Ejemplo n.º 3
0
 public async Task Create(CredentialRole credentialRole)
 {
     Roles.Add(credentialRole);
 }