private void Auth()
 {
     if (Pro.ScoreCondition != ProjectScoreCondition.Scored)
     {
         endproject.IsEnabled = false;
     }
     if (Claims.Roles.Count() == 0 || Pro.Condition == ProjectCondition.Finished)
     {
         AddManager_btn.IsEnabled    = false;
         deleteproject_btn.IsEnabled = false;
         endproject.IsEnabled        = false;
         piliang.IsEnabled           = false;
         AddVolunteer_btn.IsEnabled  = false;
     }
     if (Claims.Roles.Count() == 1 && Claims.IsInRole(AppRoleEnum.OrgnizationMember))
     {
         AddManager_btn.IsEnabled       = false;
         deleteproject_btn.IsEnabled    = false;
         project_manager_list.IsEnabled = false;
         AddManager.IsEnabled           = false;
         AddManager_btn.IsEnabled       = false;
     }
     if (Claims.Roles.Count() == 1 && Claims.IsInRole(AppRoleEnum.OrgnizationAdministrator))
     {
         endproject.IsEnabled       = false;
         piliang.IsEnabled          = false;
         AddVolunteer_btn.IsEnabled = false;
     }
 }
Example #2
0
 public ProjectCreate()
 {
     Claims = basepage.Claims;
     helper = ProjectManageHelper.GetInstance();
     //Login.GetClaims(sendClaimsEventHandler);
     InitializeComponent();
     if (Claims.IsInRole(AppRoleEnum.Administrator) || Claims.IsInRole(AppRoleEnum.OrgnizationAdministrator))
     {
         this.IsEnabled = true;
     }
     else
     {
         this.IsEnabled = false;
     }
 }
 public UserApproval()
 {
     InitializeComponent();
     Claims = identitypage.Claims;
     if (Claims.IsInRole(AppRoleEnum.Administrator))
     {
         addorganization_btn.Visibility = Visibility.Visible;
     }
     if (Claims.IsInRole(AppRoleEnum.Administrator) || Claims.IsInRole(AppRoleEnum.OrgnizationAdministrator))
     {
         this.IsEnabled            = true;
         approvallist              = helper.ShowNotApprovedMembers(Claims.User.Organization);
         approval_list.ItemsSource = approvallist;
     }
     else
     {
         this.IsEnabled = false;
     }
 }
 public Register(AppUserIdentityClaims claims = null, Login login = null)
 {
     identityhelper = IdentityHelper.GetInstance();
     loginWindow    = login;
     if (claims != null && claims.IsInRole(AppRoleEnum.Administrator))
     {
         isAdministrator = true;
     }
     InitializeComponent();
 }
        public void AddToRoleTest()
        {
            string  accountName = "!@#$%^&*()_+-=1234567890qwertyuiop[]\\{}|asdfghjkl;':\"zxcvbnm,./<>?";
            AppUser dbUser      = database.Users.SingleOrDefault(u => u.AccountName == accountName);

            if (dbUser != null)
            {
                database.Users.Remove(dbUser);
                database.SaveChanges();
            }

            AppUser user = new AppUser
            {
                Name        = "张三李四·.",
                AccountName = accountName,
                Email       = "*****@*****.**",
                Mobile      = "18888888888"
            };
            string         password = "******"zxcvbnm,./<>?";
            IdentityResult result   = helper.CreateUser(user, password, AppRoleEnum.OrgnizationMember, OrganizationEnum.SEA团队);

            if (!result.Succeeded)
            {
                Assert.Inconclusive("CreateUser方法运行失败,本测试无法运行。");
            }
            dbUser = database.Users.SingleOrDefault(u => u.AccountName == user.AccountName);
            helper.AddToRole(dbUser.Id, AppRoleEnum.LogViewer);
            AppUserIdentityClaims claims = helper.CreateClaims(user.AccountName, password);

            if (!claims.IsAuthenticated)
            {
                Assert.Inconclusive("CreateClaims方法运行失败,未取得IdentityClaims。");
            }
            if (!claims.IsInRole(AppRoleEnum.LogViewer))
            {
                Assert.Fail("角色添加失败!");
            }
            database.Users.Remove(dbUser);
            database.SaveChanges();
        }