diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-01-21 13:53:00 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-01-21 13:53:00 +0200 |
| commit | 63579cee4493c4a8e3d64348d644fd2eecaca055 (patch) | |
| tree | bc8e92b3a2751c5fe186ad9af08d88ad8fc02628 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs | |
| parent | 1d69ae8399a8e2419af3c4391ea387f5180561c3 (diff) | |
| download | Tango-63579cee4493c4a8e3d64348d644fd2eecaca055.tar.gz Tango-63579cee4493c4a8e3d64348d644fd2eecaca055.zip | |
PPC v1.0.0
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index 516349a18..f926a0f4c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -21,6 +21,7 @@ using Tango.PPC.Jobs; using Tango.SharedUI; using System.Data.Entity; using Tango.BL.Enumerations; +using Tango.BL.Builders; namespace Tango.PPC.UI.ViewModels { @@ -79,7 +80,19 @@ namespace Tango.PPC.UI.ViewModels if (db.Users.Count() == 1 || machine.AutoLogin) { - var user = await db.Users.FirstAsync(); + var user = await new UserBuilder(db).SetFirst().WithRolesAndPermissions().BuildAsync(); + + if (!user.HasRole(Roles.PPCUser)) + { + var role = db.Roles.Single(x => x.Code == (int)Roles.PPCUser); + user.Roles.Add(role); + db.UsersRoles.Add(new BL.Entities.UsersRole() + { + User = user, + Role = role, + }); + await db.SaveChangesAsync(); + } LogManager.Log($"Application started. Single user/Auto login detected ({user.Email}). Skipping LoginView..."); await AuthenticationProvider.Login(user.Email, user.Password, false); |
