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); }
public static void Logout() { PTIdentity identity = PTIdentity.UnauthenticatedIdentity(); PTPrincipal principal = new PTPrincipal(identity); Csla.ApplicationContext.User = principal; }
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); }
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)); }
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)); }
public static async Task LoginAsync(string username, string password) { try { var identity = await PTIdentity.GetPTIdentityAsync(username, password); SetPrincipal(identity); } catch (Exception ex) { Logout(); } }
public static async System.Threading.Tasks.Task LoginAsync(string username, string password) { try { var identity = await PTIdentity.GetPTIdentityAsync(username, password); SetPrincipal(identity); } catch { Logout(); } }
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(); } }); }
public static bool Login(string username, string password) { var identity = PTIdentity.GetPTIdentity(username, password); return(SetPrincipal(identity)); }
public static bool Load(string username) { var identity = PTIdentity.GetPTIdentity(username); return(SetPrincipal(identity)); }
public override bool IsInRole(string role) { PTIdentity identity = (PTIdentity)this.Identity; return(identity.IsInRole(role)); }