public void Start() { _currentUser = ClientEnvironment.AuthorizationService.GetCurrentUser(); if(!_currentUser.UserRoleID.HasValue || (UserRoleId.GlobalAdmin != (UserRoleId)_currentUser.UserRoleID.Value && UserRoleId.CountryAdmin != (UserRoleId)_currentUser.UserRoleID.Value && UserRoleId.RegionAdmin != (UserRoleId)_currentUser.UserRoleID.Value && UserRoleId.StoreAdmin != (UserRoleId)_currentUser.UserRoleID.Value)) { return; } // Initialize checker thread _checkerThread = new Thread(Check); _checkerThread.IsBackground = true; ShowProgress(); _checkerThread.Start(); }
internal UserItem(User user, CultureInfo culture) { _ClientCulture = culture; _User = user; }
private Guid RegisterUser(User user) { Guid id = Guid.NewGuid(); try { GenuineUtility.CurrentSession["id"] = new SessionId(id); } catch {} LocalDataStoreSlot slot = Thread.GetNamedDataSlot(UserSlot); Thread.SetData(slot, user); user.Password = null; try { _Sync.AcquireWriterLock(Timeout.Infinite); _AuthorizedUsers.Add(id, new UserItem(user, null)); if (user.UserRoleID != null) { UserRole role = _RoleSvc.FindById((long)user.UserRoleID); if (role != null) { _UsersPermissions.AddRole(role, _Services); } } } finally { _Sync.ReleaseWriterLock(); } return id; }
private static bool CheckPassword(string password, User usr) { if (string.IsNullOrEmpty(usr.Password)) return true; string hashedPassword = SaltHashing.ComputeSaltedHash(password, usr.Salt); return usr.Password == hashedPassword; }
public LoginResult LoginVersionCheck(string login, string password, out User resultUser, Version clientVersion) { CheckClientVersion(clientVersion); // check if user already logged in and if Yes then logout before login Logout(); resultUser = null; User user = _UserSvc.GetByLogin(login); if (user != null) { if (!user.Active) { return LoginResult.UserIsInactive; } if (string.IsNullOrEmpty(user.Password)) { Guid id = RegisterUser(user); resultUser = user; if (log.IsDebugEnabled) { log.Debug(string.Format("User login: {0}, Session id:{1}", user.LoginName, id)); } return LoginResult.Successful; } else { if (CheckPassword(password, user)) { Guid id = RegisterUser(user); resultUser = user; if (log.IsDebugEnabled) { log.Debug(string.Format("User login: {0}, Session id:{1}", user.LoginName, id)); } return LoginResult.Successful; } else { if (log.IsDebugEnabled) { log.Debug(string.Format("Login failed: wrong password")); } return LoginResult.WrongPassword; } } } else { return LoginResult.WrongLogin; } }
public LoginResult Login(string login, string password, out User resultUser) { return LoginVersionCheck(login, password, out resultUser, null); }
public UserInfo(User user) { User = user; }
public void Logout() { _LogonUser = null; if (_SvcAccess != null) { _SvcAccess.Clear(); } _RemoteSvc.Logout(); }
public LoginResult LoginVersionCheck(string login, string password, out User resultUser, Version clientVersion) { _SvcAccess = null; _LogonUser = null; LoginResult res; SecuritySessionParameters oldParams = SecuritySessionServices.SetCurrentSecurityContext( new SecuritySessionParameters("/BAUMAX/SES", SecuritySessionAttributes.ForceSync, TimeSpan.MinValue, GenuineConnectionType.Persistent, null, TimeSpan.FromSeconds(10))); try { res = _RemoteSvc.LoginVersionCheck(login, password, out resultUser, clientVersion); _LogonUser = resultUser; } finally { SecuritySessionServices.SetCurrentSecurityContext(oldParams); } return res; }