private void InvokeOnRemoveUser(User user) { var eventArgs = new UserEventArgs(user); if (_onRemoveUser != null) try { _onRemoveUser(this, eventArgs); }catch(Exception e) { DataBaseManager.Logger.Log(String.Format("InvokeOnRemoveUser fail - {0}", e.Message)); } }
private void InvokeOnUserChangePassword(User user, string passwordPlainText) { var eventArgs = new UserEventArgs(user); if (_onUserChangePassword != null) try { _onUserChangePassword(this, eventArgs); } catch (Exception e) { DataBaseManager.Logger.Log(String.Format("InvokeOnUserChangePassword fail - {0}", e.Message)); } }
private void InheritedEnrollParents(User user, Container container, RoleType roleType) { var current = container; while (current != null){ if (!PermissionToEnroll(current, roleType, RoleBarrier.Bottom)) return; EnrollInherited(user, current, roleType); current = current.Parent; } }
public UserEventArgs(User user, string passwordPlainText) : this(user) { PasswordPlainText = passwordPlainText; }
public UserEventArgs(User user) { User = user; }
private void InheritedEnrollChilds(User user, Container container, RoleType roleType) { foreach (var child in container.Childs) { if (!PermissionToEnroll(child, roleType, RoleBarrier.Top)) continue; EnrollInherited(user, child, roleType); InheritedEnrollChilds(user, child, roleType); } }
private bool InheritedDisenroll(User user, Container container, RoleType roleType) { var enroll = _db.DbContext.Enrolls.Find(user.Name, container.Id, roleType.Name, container.Type.StructureId); if (enroll == null) return false; enroll.InheritedCount -= 1; if (enroll.InheritedCount == 0) if (enroll.Inherited) { _db.DbContext.Enrolls.Remove(enroll); InvokeOnDisenrollUser(enroll, container); } return true; }
private bool EnrollInherited(User user, Container container, RoleType roleType) { var enroll = _db.DbContext.Enrolls.Find(user.Name, container.Id, roleType.Name, container.Type.StructureId); if (enroll != null) { enroll.InheritedCount += 1; return true; } enroll = new Enroll() { User = user, Container = container, RoleType = roleType, Inherited = true, InheritedCount = 1 }; _db.DbContext.Enrolls.Add(enroll); InvokeOnEnrollUser(enroll); return true; }
public User Create(string name, string password, string email) { var user = new User { Name = name, Credential = AuthenticationManager.EncryptPassword(password), Email = email }; _db.DbContext.Users.Add(user); _db.DbContext.SaveChanges(); InvokeOnCreateUser(user, password); return user; }