aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs
new file mode 100644
index 000000000..8a60caf6d
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs
@@ -0,0 +1,45 @@
+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
+{
+ public class DefaultAuthenticationProvider : ExtendedObject, IAuthenticationProvider
+ {
+ private User _currentUser;
+
+ public User CurrentUser
+ {
+ get { return _currentUser; }
+ private set
+ {
+ _currentUser = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ public event EventHandler<User> CurrentUserChanged;
+
+ public Task<User> Login(string email, string password)
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ CurrentUser = ObservablesEntitiesAdapter.Instance.Users.SingleOrDefault(x => x.Email.ToLower() == email && x.Password == password);
+ CurrentUserChanged?.Invoke(this, CurrentUser);
+ return CurrentUser;
+ });
+ }
+
+ public void Logout()
+ {
+ CurrentUser = null;
+ CurrentUserChanged?.Invoke(this, CurrentUser);
+ }
+ }
+}