private bool EnableMainSoftKeys(MainSoftKeys.ButtonConfig BtCfg) { User.EnuUserRole _Role = UserManager.getUserManager.GetCurrentUser().Role; string Function = BtCfg.GetValue(); if (_Role < User.EnuUserRole.User && (Function == "SettingsType" || Function == "HomingStart" || Function == "AutomaticStart" || Function == "AutomaticStartOnce" || Function == "LogHistory" )) { return(false); } if (_Role < User.EnuUserRole.Supervisor && ( Function == "ManualMode" || Function == "PLC1" || Function == "Trace1" )) { return(false); } return(true); }
public Boolean CanCreateUser(string Name, string Password, User.EnuUserRole Role) { if (m_Users == null) { return(false); } if (GetCurrentUser().Role < User.EnuUserRole.Supervisor) { return(false); } if (Role > GetCurrentUser().Role) { return(false); } if (Name.Length < 4) { return(false); } if (Password.Length < 4) { return(false); } if (m_Users.ContainsKey(Name)) { return(false); } return(true); }
/// <summary> /// returns Guest on unknown user /// </summary> /// <param name="Name"></param> /// <returns></returns> public User.EnuUserRole GetUserRole(string Name) { User.EnuUserRole _Role = User.EnuUserRole.Guest; if (m_Users.ContainsKey(Name)) { _Role = m_Users[Name].Role; } return(_Role); }
/// <summary> /// Anlegen nur zulässig wenn: /// - angemeldete UserRole mindestens Supervisor /// - anzulegende UserRole kleiner/gleich angemeldete User-Role /// - anzulegender User noch nicht vorhanden /// - User-Name mindestens 4 Zeichen /// - Password mindestens 4 Zeichen /// </summary> /// <param name="Name"></param> /// <param name="Password"></param> /// <param name="Role"></param> /// <returns></returns> public Boolean CreateUser(string Name, string Password, User.EnuUserRole Role) { if (!CanCreateUser(Name, Password, Role)) { return(false); } m_Users.Add(Name, User.CreateUser(Name, Password, Role)); Save(); return(true); }
public Boolean CanModifyRole(string Name, User.EnuUserRole Role) { if (m_Users == null) { return(false); } if (m_Users.ContainsKey(Name)) { return(false); } if (Role > GetCurrentUser().Role) { return(false); } return(true); }
/// <summary> /// Ändern nur zulässig wenn: /// - angemeldete UserRole mindestens Supervisor /// - User vorhanden /// - anzulegende UserRole kleiner/gleich angemeldete User-Role (man kann einem User oder sich selbst nicht eine höhere Role geben als man selbst hat) /// Wurde der angemeldete User geändert, wird er abgemeldet. /// </summary> /// <param name="Name"></param> /// <param name="Password"></param> /// <param name="Role"></param> /// <returns></returns> public Boolean ModifyRole(string Name, User.EnuUserRole Role) { if (!CanModifyRole(Name, Role)) { return(false); } User _user = User.CreateUserEncrypPass(Name, m_Users[Name].EncryptedPassword, Role); m_Users[Name] = _user; Save(); if (GetCurrentUser().Name == Name) { Logout(); } return(true); }