aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-28 16:35:16 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-28 16:35:16 +0300
commitf3fc87dd10b3d55591a84ecbfb0612769f0c09b9 (patch)
tree640621ab876dd5368d91e44b07b4f2872752e5bb /Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication
parent37fe17f09478a486dcd51f0edd8028724dc85c16 (diff)
downloadTango-f3fc87dd10b3d55591a84ecbfb0612769f0c09b9.tar.gz
Tango-f3fc87dd10b3d55591a84ecbfb0612769f0c09b9.zip
Working on BL Builders !
Working on making PPC work with builders..
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs41
1 files changed, 26 insertions, 15 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
index 3dae9d05a..23761eb9b 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL;
+using Tango.BL.Builders;
using Tango.BL.Entities;
using Tango.Core;
using Tango.Core.DI;
@@ -50,24 +51,34 @@ namespace Tango.PPC.UI.Authentication
/// <param name="email">The email.</param>
/// <param name="password">The password.</param>
/// <returns></returns>
- public User Login(string email, string password)
+ public Task<User> Login(string email, string password)
{
- String hash = User.GetPasswordHash(password);
-
- LogManager.Log($"Logging in user {email}...");
- CurrentUser = ObservablesStaticCollections.Instance.Users.SingleOrDefault(x => x.Email.ToLower() == email && x.Password == hash);
-
- if (CurrentUser != null)
- {
- LogManager.Log($"Current user is now: {CurrentUser.Contact.FullName}.");
- }
- else
+ return Task.Factory.StartNew<User>(() =>
{
- LogManager.Log("Login failed!");
- }
+ String hash = User.GetPasswordHash(password);
- CurrentUserChanged?.Invoke(this, CurrentUser);
- return CurrentUser;
+ LogManager.Log($"Logging in user {email}...");
+
+ using (var db = ObservablesContext.CreateDefault())
+ {
+ CurrentUser = new UserBuilder(db).Set(x => x.Email.ToLower() == email && x.Password == hash)
+ .WithOrganization()
+ .WithRolesAndPermissions()
+ .Build();
+ }
+
+ if (CurrentUser != null)
+ {
+ LogManager.Log($"Current user is now: {CurrentUser.Contact.FullName}.");
+ }
+ else
+ {
+ LogManager.Log("Login failed!");
+ }
+
+ CurrentUserChanged?.Invoke(this, CurrentUser);
+ return CurrentUser;
+ });
}
/// <summary>