示例#1
0
        public static System.Threading.Tasks.Task LoginAsync(string username, string password)
        {
            var tcs = new System.Threading.Tasks.TaskCompletionSource <PTPrincipal>();

            PTIdentity.GetPTIdentity(username, password, (o, e) =>
            {
                if (e.Error == null && e.Object != null)
                {
                    SetPrincipal(e.Object);
                    tcs.SetResult(null);
                }
                else
                {
                    Logout();
                    if (e.Error != null)
                    {
                        tcs.SetException(e.Error.InnerException);
                    }
                    else
                    {
                        tcs.SetCanceled();
                    }
                }
            });
            return(tcs.Task);
        }
示例#2
0
        public static void Logout()
        {
            PTIdentity  identity  = PTIdentity.UnauthenticatedIdentity();
            PTPrincipal principal = new PTPrincipal(identity);

            Csla.ApplicationContext.User = principal;
        }
示例#3
0
        public static bool Login(string username, string password)
        {
            PTIdentity identity =
                PTIdentity.GetIdentity(username, password);

            if (identity.IsAuthenticated)
            {
                PTPrincipal principal = new PTPrincipal(identity);
                Csla.ApplicationContext.User = principal;
            }
            return(identity.IsAuthenticated);
        }
示例#4
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 identity = await PTIdentity.GetPTIdentityAsync(username);

            return(SetPrincipal(identity));
        }
示例#5
0
        public static bool Load(string username)
        {
            var current = Csla.ApplicationContext.User;

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

            var identity = PTIdentity.GetPTIdentity(username);

            return(SetPrincipal(identity));
        }
示例#6
0
        public static async Task LoginAsync(string username, string password)
        {
            try
            {
                var identity = await PTIdentity.GetPTIdentityAsync(username, password);

                SetPrincipal(identity);
            }
            catch (Exception ex)
            {
                Logout();
            }
        }
示例#7
0
文件: PTPrincipal.cs 项目: wyerp/csla
        public static async System.Threading.Tasks.Task LoginAsync(string username, string password)
        {
            try
            {
                var identity = await PTIdentity.GetPTIdentityAsync(username, password);

                SetPrincipal(identity);
            }
            catch
            {
                Logout();
            }
        }
示例#8
0
 public static void BeginLogin(string username, string password)
 {
     PTIdentity.GetPTIdentity(username, password, (o, e) =>
     {
         if (e.Error == null && e.Object != null)
         {
             SetPrincipal(e.Object);
         }
         else
         {
             Logout();
         }
     });
 }
示例#9
0
        public static bool Login(string username, string password)
        {
            var identity = PTIdentity.GetPTIdentity(username, password);

            return(SetPrincipal(identity));
        }
示例#10
0
文件: PTPrincipal.cs 项目: wyerp/csla
        public static bool Load(string username)
        {
            var identity = PTIdentity.GetPTIdentity(username);

            return(SetPrincipal(identity));
        }
示例#11
0
        public override bool IsInRole(string role)
        {
            PTIdentity identity = (PTIdentity)this.Identity;

            return(identity.IsInRole(role));
        }