aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
diff options
context:
space:
mode:
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.cs15
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);