using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL; using Tango.BL.Entities; using Tango.Core; using Tango.PPC.Common.Authentication; namespace Tango.PPC.UI.Authentication { /// /// Represents the default PPC authentication provider. /// /// /// public class DefaultAuthenticationProvider : ExtendedObject, IAuthenticationProvider { /// /// Occurs when the current logged-in user has changed. /// public event EventHandler CurrentUserChanged; private User _currentUser; /// /// Gets the current logged-in user. /// public User CurrentUser { get { return _currentUser; } private set { _currentUser = value; RaisePropertyChangedAuto(); } } /// /// Performs a user login by the specified email and password. /// /// The email. /// The password. /// public User Login(string email, string password) { CurrentUser = ObservablesEntitiesAdapter.Instance.Users.SingleOrDefault(x => x.Email.ToLower() == email && x.Password == password); CurrentUserChanged?.Invoke(this, CurrentUser); return CurrentUser; } /// /// Logs-out the current logged-in user. /// public void Logout() { CurrentUser = null; CurrentUserChanged?.Invoke(this, CurrentUser); } } }