Example #1
0
 private static bool SetPrincipal(ICslaIdentity identity)
 {
     if (identity.IsAuthenticated)
     {
         PTPrincipal principal = new PTPrincipal(identity);
         Csla.ApplicationContext.User = principal;
         PrincipalCache.AddPrincipal(principal);
     }
     OnNewUser();
     return(identity.IsAuthenticated);
 }
Example #2
0
        public static async Task <bool> LoadAsync(string username)
        {
            var current = Csla.ApplicationContext.User;

            if (current != null && current.Identity != null && current.Identity.Name == username)
            {
                return(true);
            }

            var fromCache = PrincipalCache.GetPrincipal(username);

            if (fromCache != null)
            {
                return(SetPrincipal(fromCache));
            }

            var identity = await PTIdentity.GetPTIdentityAsync(username);

            return(SetPrincipal(identity));
        }