/// <summary> /// Initialises a new instance of the <see cref="User"/> class. /// </summary> /// <param name="id">The unique id of this instance.</param> /// <param name="username">The username of this instance.</param> /// <param name="privileges">The privileges associated with this instance.</param> /// <param name="email">The optional email of this instance.</param> public User(ulong id, string username, UserPrivileges privileges, string email = null) { Id = id; Username = username; Privileges = privileges; Email = email; }
public Privilege(UserPrivileges privileges) { if (privileges == UserPrivileges.Supervisor) { this.BloodlettingReport = this.CashReport = this.CashReportParish = this.Employee = this.Minister = this.Schedule = true; } else if (privileges == UserPrivileges.Treasurer) { this.CashReport = this.CashReportParish = this.CashReceipt = this.CashReceiptParish = this.CashDisbursement = this.ItemType = true; } else { this.CashReportParish = this.CashReceiptParish = this.Bloodletting = this.BloodlettingReport = this.Schedule = true; } }
public User(string password, string fullName, UserPrivileges privileges, string eMail) { _password = password; _fullname = fullName; _privileges = privileges; _eMail = eMail; }
private void addButton_Click(object sender, EventArgs e) { bool success = false; bool isDisablingOwnAcc = false; try { UserPrivileges privilege = (UserPrivileges)cmbEmployeeType.SelectedIndex; if (txtAdd.Tag.ToString() == "a") { success = login.AddUser(txtFirstName.Text, txtMI.Text, txtLastName.Text, txtSuffix.Text, txtUsername.Text, txtPassword.Text, privilege); refresEmployees(); clearFields(); } else { UserStatus status = active_checkbox.Checked ? UserStatus.Active : UserStatus.Inactive; int _userID = Convert.ToInt32(employeeID_label.Text); if (user.userID == _userID && status == UserStatus.Inactive) { DialogResult dr = MessageDialog.Show("Disabling your account will cause you to log out. Proceed?", MessageDialogButtons.YesNo, MessageDialogIcon.Warning); isDisablingOwnAcc = dr == DialogResult.Yes; } if (txtPassword.Enabled) { success = login.editUserResetPassword(txtFirstName.Text, txtMI.Text, txtLastName.Text, txtSuffix.Text, txtUsername.Text, txtPassword.Text, status, privilege, int.Parse(employeeID_label.Text)); } else { success = login.editEmployee(txtFirstName.Text, txtMI.Text, txtLastName.Text, txtSuffix.Text, txtUsername.Text, status, privilege, int.Parse(employeeID_label.Text)); } txtAdd.Tag = "a"; txtAdd.Text = "Add"; refresEmployees(); clearFields(); } } catch { Notification.Show(State.DuplicateUsername); } if (success) { Notification.Show(State.UserUpdateSuccess); } else { Notification.Show(State.UserUpdateFail); } if (isDisablingOwnAcc) { this.Owner.Close(); } }
public User(int? _id, string _name, string _surname, string _address, UserPrivileges _privilege) { Id = _id; Name = _name; Surname = _surname; Address = _address; Privilege = _privilege; }
public static void Add(UserPrivileges up) { using (var db = new LibraryDBEntities()) { db.UserPrivileges.Add(up); db.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { UserPrivileges userPrivileges = db.userprivileges.Find(id); db.userprivileges.Remove(userPrivileges); db.SaveChanges(); return(RedirectToAction("Index")); }
public static void Update(UserPrivileges up) { using (var db = new LibraryDBEntities()) { db.Entry(up).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
/// <summary> /// Initialises a new instance of the <see cref="User"/> class. /// </summary> /// <param name="id">The unique id of this instance.</param> /// <param name="username">The username of this instance.</param> /// <param name="privileges">The privileges associated with this instance.</param> /// <param name="passwordHash">The hash of the salted password of this instance.</param> /// <param name="passwordSalt">The salt used to hash the password.</param> /// <param name="email">The optional email of this instance.</param> public User(ulong id, string username, UserPrivileges privileges, byte[] passwordHash, byte[] passwordSalt, string email = null) { Id = id; Username = username; Privileges = privileges; PasswordHash = passwordHash; PasswordSalt = passwordSalt; Email = email; }
public void GetCurrentUserPrivilegesTest() { PrivateObject param0 = null; // TODO: Initialize to an appropriate value BaseController_Accessor target = new BaseController_Accessor(param0); // TODO: Initialize to an appropriate value UserPrivileges expected = new UserPrivileges(); // TODO: Initialize to an appropriate value UserPrivileges actual; actual = target.GetCurrentUserPrivileges(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public static string GetEnumDescription(this UserPrivileges value) { FieldInfo fi = value.GetType().GetField(value.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes( typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : value.ToString()); }
public ActionResult Edit([Bind(Include = "UserPrivilegesID,UserName,PrivilegeID")] UserPrivileges userPrivileges) { if (ModelState.IsValid) { db.Entry(userPrivileges).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PrivilegeID = new SelectList(db.privilege, "PrivilegeID", "Description", userPrivileges.PrivilegeID); ViewBag.UserName = new SelectList(db.user, "UserName", "Password", userPrivileges.UserName); return(View(userPrivileges)); }
//Popup_Notification_Window PNW; public ClientPresentation() { InitializeComponent(); VM = new PresentationViewModel(); if (ClientKeeper.NPC != null && ClientKeeper.NPC.OnAir) { VM.isConnected = true; //Debug.InformByPopupWindow(ServerTechInfo.Accomplished, "Добро пожаловать, " + ClientKeeper.NPC.Username); Task X = Task.Run(() => { UserPrivileges up = ClientKeeper.NPC.GetPrivileges(); switch (up) { case UserPrivileges.Admin: VM.PathData = (Geometry)this.Resources["chess_kingStyle"]; break; case UserPrivileges.Guest: Dispatcher.BeginInvoke(new Action(() => { setGuestRestrictions(); })); Dispatcher.BeginInvoke(new Action(() => { setUserRestrictions(); })); VM.PathData = (Geometry)this.Resources["chess_bishopStyle"]; break; case UserPrivileges.User: Dispatcher.BeginInvoke(new Action(() => { setUserRestrictions(); })); VM.PathData = (Geometry)this.Resources["chess_bishopStyle"]; break; } }); } this.DataContext = VM; #region hide //ClosableTabItem CTI = new ClosableTabItem(); //TextBlock H = new TextBlock() { Text = "TEHNOBLOG" }; //CTI.SetHeader(H); //CTI.Style = (Style)this.Resources["TabItemStyle"]; //Tabs.Items.Add(CTI); //ClosableTabItem CTI2 = new ClosableTabItem(); //TextBlock H2 = new TextBlock() { Text = "pizdec" }; //CTI2.SetHeader(H2); //CTI2.Style = (Style)this.Resources["TabItemStyle"]; //Tabs.Items.Add(CTI2); //PNW = new Popup_Notification_Window(); //PNW.Show(); //DispatcherTimer T = new DispatcherTimer(); //T.Interval = new TimeSpan(0, 0, 2); //T.Tick += new EventHandler((object s, EventArgs e) => { NamedPipeClient.ShowNotification("раз два проверка", RealtyDB.Commands.ServerTechInfo.Accomplished); T.Stop(); }); //T.Tick += new EventHandler((object s, EventArgs e) => { Popup_Notification_Window PNW = new Popup_Notification_Window(); T.Stop(); }); //T.Start(); #endregion }
// GET: UserPrivileges/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserPrivileges userPrivileges = db.userprivileges.Find(id); if (userPrivileges == null) { return(HttpNotFound()); } return(View(userPrivileges)); }
//USER SESSION VARIABLE is @userID private User(int userID, string firstName, string midName, string lastName, string suffix, string userName, string password, UserStatus status, int addedBy, UserPrivileges privileges) { this.userID = userID; this.firstName = firstName; this.midName = midName; this.lastName = lastName; this.suffix = suffix; this.userName = userName; this._password = password; this._status = status; this.addedBy = addedBy; this.Privilege = (int)privileges; this.userPrivilegeLevel = privileges; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (UserPrivileges.IsUserAdministrator()) { Application.Run(new MainWindow()); } else { MessageBox.Show(@"You need to start this application in administrator mode in order to edit environment variables.\n Please Run as Administrator", "Admin Rights Required", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public override void FinishInitialization() { base.FinishInitialization(); foreach (var userPrivilege in UserPrivileges.Where(p => !p.IsSystemGeneratedObject)) { if (userPrivilege.ObjectType == ObjectType.PACKAGE) { userPrivilege.Package = Metadata .MetadataPackages .PackagesByName[userPrivilege.ObjectName]; } } }
protected override void ApplyCommandExecuted() { if (_passwordWasChanged) { _data.Password = Password.ToMD5Hash(); } ; if (_privilesWereChanged) { var list = UserPrivileges.Cast <Models.Privilege>(); _data.Privileges.Replace(list); } ; _dc.SaveChanges(); }
public static string [] UserPrivilegesArray(int Value) { string [] values; string value_list; UserPrivileges up_mask = (UserPrivileges)Value; value_list = up_mask.ToString("G"); values = value_list.Split(','); for (int i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); } return(values); }
// GET: UserPrivileges/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserPrivileges userPrivileges = db.userprivileges.Find(id); if (userPrivileges == null) { return(HttpNotFound()); } ViewBag.PrivilegeID = new SelectList(db.privilege, "PrivilegeID", "Description", userPrivileges.PrivilegeID); ViewBag.UserName = new SelectList(db.user, "UserName", "Password", userPrivileges.UserName); return(View(userPrivileges)); }
private void BtnCreate_Click(object sender, EventArgs e) { epUserName.Clear(); bool check1 = SessionsHelper.ControlValidate(txtUserName, "Lütfen User Name Giriniz.", epUserName); epPassword.Clear(); bool check2 = SessionsHelper.ControlValidate(txtEnterPassword, "Lütfen Password Giriniz.", epPassword); if (txtEnterPassword.Text.Trim() != txtConfirmPassword.Text.Trim()) { epConfirmPass.Clear(); epConfirmPass.SetError(txtConfirmPassword, "Şifreler eşleşmiyor!"); return; } if (check1 && check2) { if (!UsersHelper.HaveUserID(txtUserName.Text.ToLower())) { UserPrivileges up = new UserPrivileges(); up.StaffID = StaffsHelper.GetByName(cmbSelectUser.SelectedItem.ToString()); up.Configuration = Convert.ToInt32(chkConfiguration.Checked); up.Book = Convert.ToInt32(chkBook.Checked); up.Report = Convert.ToInt32(chkReport.Checked); up.Staff = Convert.ToInt32(chkStaff.Checked); up.IssueBook = Convert.ToInt32(chkIssueBook.Checked); up.Gsm = Convert.ToInt32(chkGSM.Checked); up.Student = Convert.ToInt32(chkStudent.Checked); up.ReturnBook = Convert.ToInt32(chkReturnBook.Checked); up.Email = Convert.ToInt32(chkEmail.Checked); UserPrivilegesHelper.Add(up); Users u = new Users(); u.StaffID = StaffsHelper.GetByName(cmbSelectUser.SelectedItem.ToString()); u.UserName = txtUserName.Text; u.Password = txtEnterPassword.Text; UsersHelper.Add(u); MessageBox.Show("Üye Ekleme Başarılı", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Eklemek istediğiniz User Name sistemde mevcuttur.", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void AfterLogin(UserPrivileges permission) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback(delegate { if (privileges == null) { if ((permission | UserPrivileges.NoUser) != 0) { if ((permission & UserPrivileges.HighPrivlidges) != 0) { OpenOwner(); } if ((permission & UserPrivileges.WarehouseAdministrator) != 0) { OpenWarehouse(); } if ((permission == UserPrivileges.Cook)) { OpenCook(); } if (permission == UserPrivileges.Waitress) { OpenWaitress(); } privileges = permission; } else { ModernDialog.ShowMessage("There is no such user in database or wrong password was provided", "Login problem", MessageBoxButton.OK); } } else { RedirectAfterLogin(); } return(null); }), null); }
public static bool loginUser(string userName, string password) { bool verified = verify(userName, password, false); if (!verified) { return(false); } DataTable dt = dh.getUser(userName); int userID = Convert.ToInt32(dt.Rows[0]["userID"].ToString()); string firstName = dt.Rows[0]["firstName"].ToString(); string midName = dt.Rows[0]["midName"].ToString(); string lastName = dt.Rows[0]["lastName"].ToString(); string suffix = dt.Rows[0]["suffix"].ToString(); UserStatus status = (UserStatus)(Convert.ToInt32(dt.Rows[0]["status"])); int addedBy = Convert.ToInt32(dt.Rows[0]["addedBy"]); UserPrivileges privileges = (UserPrivileges)(Convert.ToInt32(dt.Rows[0]["privileges"])); _user = new User(userID, firstName, midName, lastName, suffix, userName, password, status, addedBy, privileges); return(true); }
public static bool HasAccess(UserPrivileges privilege) { return(_userPrivileges.Contains(privilege)); }
/// <summary> /// validate if the user has the privilege to access a specific list or list item /// </summary> /// <param name="context"></param> /// <param name="output"></param> public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = null; if (!IsSuperAdmin) { //if the user check for a list if (!string.IsNullOrEmpty(UlPrivilegs)) { switch (UlPrivilegs) { case UlPrivilegsConst.Approval: if (UserPrivileges != null && UserPrivileges.Any(x => x.CanApprove)) { return; } output.SuppressOutput(); return; case UlPrivilegsConst.HomePage: if (UserPrivileges != null && UserPrivileges.Any(x => x.PageTypeId >= PrivilegesPageType.HPBasicInfo && x.PageTypeId <= PrivilegesPageType.HPAffiliates && x.CanView)) { return; } output.SuppressOutput(); return; case UlPrivilegsConst.Definitions: if (UserPrivileges != null && UserPrivileges.Any(x => (x.PageTypeId == PrivilegesPageType.NewsType || x.PageTypeId == PrivilegesPageType.DynamicPage || x.PageTypeId == PrivilegesPageType.StaticPage || x.PageTypeId == PrivilegesPageType.LeftMenuItems || x.PageTypeId == PrivilegesPageType.FooterMenuItems || x.PageTypeId == PrivilegesPageType.FooterMenuTitles || x.PageTypeId == PrivilegesPageType.NavItems) && x.CanView)) { return; } output.SuppressOutput(); return; case UlPrivilegsConst.EconomicIndicators: if (UserPrivileges != null && UserPrivileges.Any(x => (x.PageTypeId == PrivilegesPageType.ComponentConstant || x.PageTypeId == PrivilegesPageType.ComponentCurrent || x.PageTypeId == PrivilegesPageType.ActivityCurrent || x.PageTypeId == PrivilegesPageType.SectorGrowthRates || x.PageTypeId == PrivilegesPageType.RGDP || x.PageTypeId == PrivilegesPageType.Investment || x.PageTypeId == PrivilegesPageType.Governorate) && x.CanView)) { return; } output.SuppressOutput(); return; case UlPrivilegsConst.Component: if (UserPrivileges != null && UserPrivileges.Any(x => (x.PageTypeId == PrivilegesPageType.ComponentConstant || x.PageTypeId == PrivilegesPageType.ComponentCurrent) && x.CanView)) { return; } output.SuppressOutput(); return; case UlPrivilegsConst.Activity: if (UserPrivileges != null && UserPrivileges.Any(x => (x.PageTypeId == PrivilegesPageType.ActivityCurrent || x.PageTypeId == PrivilegesPageType.SectorGrowthRates) && x.CanView)) { return; } output.SuppressOutput(); return; } } //if the user check for controller if (!string.IsNullOrEmpty(SPControllerName)) { if (UserPrivileges != null && UserPrivileges.Any(x => x.PageRoute?.ControllerName?.ToLower().Trim() == SPControllerName.ToLower().Trim() && x.PageTypeId == PageTypeId && x.CanView)) { return; } } else { if (UserPrivileges != null && UserPrivileges.Any(x => x.PageTypeId == PageTypeId && x.CanView)) { return; } } output.SuppressOutput(); } return; }
/// <summary> /// create user DTO based on current user and additional information from /// specified playlist /// </summary> /// /// <param name="playlist"> /// playlist to extract data from /// </param> /// /// <param name="defaultPriv"> /// default user privileges to be set in the DTO, if not specified, /// will be detected based on current user access to specified playlist /// </param> /// /// <returns> /// mapped user DTO object /// </returns> protected UserDTO BuildUserDTO(Playlist playlist, UserPrivileges defaultPriv = UserPrivileges.NotSet) { var priv = (defaultPriv != UserPrivileges.NotSet) ? defaultPriv : GetCurrentUserPrivileges(playlist); var usrDTO = UserDTOFactory.Map( CurrentUser, CurrentUserFBInfo, playlist, priv); if (usrDTO != null) { return usrDTO; } /* return default values */ return new UserDTO { //these two values are always available via the connect cookie IsPageAdmin = CurrentUserFBInfo.IsAdmin, HasLikedPage = CurrentUserFBInfo.HasLikedPage, TimeOffset = CurrentUserFBInfo.TimeOffset, //default values FBID = -1, name = string.Empty, numOfSongsLeft = -1, role = "None", score = 0, summedScore = 0, }; }
/// <summary> /// compare user privileges /// </summary> /// /// <param name="current"> /// level of access of current user /// </param> /// /// <param name="required"> /// required level of access /// </param> /// /// <returns> /// true if there is a match, false otherwise /// </returns> /// /// <remarks> /// This method should be used instead of simple comparison. This is /// required for future expansion, for example, administrator of the /// system is always a regular user. someday we may decide that if /// current user access level is administrator and required level is /// user, we may return return "true" too. /// </remarks> protected bool MatchUserPrivilege(UserPrivileges current, UserPrivileges required) { return current == required; }
public static string ToReadable(this UserPrivileges data) { return(PrivligesNames.ContainsKey(data) ? PrivligesNames[data] : "unknown"); }
/// <summary> /// is the current usere admin of relevant fan page? /// </summary> /// /// <param name="user"> /// user to be mapped /// </param> /// /// <param name="playlist"> /// playlist with which current operation is executed /// </param> /// /// <param name="privileges"> /// additional information: user privileges to be set in returned /// object /// </param> /// /// <param name="loggedInUserInfo"> /// cookie information about currently logged in user /// </param> /// /// <returns> /// mapped user object with additional information /// </returns> public static UserDTO Map(FbUser user, FbCookieInfo loggedInUserInfo, Playlist playlist, UserPrivileges privileges = UserPrivileges.None) { if (user == null) { return null; } var userDTO = MemberDTOFactory.Map<UserDTO>(user, playlist); userDTO.role = privileges.ToString(); userDTO.IsPageAdmin = loggedInUserInfo.IsAdmin; userDTO.HasLikedPage = loggedInUserInfo.HasLikedPage; if (playlist == null) { return userDTO; } if (loggedInUserInfo.IsAdmin) { userDTO.name = playlist.LocalBusiness.Name; userDTO.FBID = playlist.LocalBusiness.FanPageId; } // TODO: test this assumption: We're assuming that since a user // doesn't have a score, it means he didn't even add a song // since he didn't add a song, that's why we can set numOfSongsAdded to playlist's max if (userDTO.score == 0) { userDTO.numOfSongsLeft = playlist.NumOfSongsLimit; } else { var userInfo = user.PlaylistsInfo.FirstOrDefault(p => p.Playlist == playlist); //TODO: remove redundant NumOfVotes column userDTO.numOfVotes = userInfo.NumOfVotes; userDTO.numOfSongsLeft = playlist.GetNumOfSongsLeft(user); } return userDTO; }
/// <summary> /// Checks whether the user has any of the the given privileges. /// </summary> /// <param name="authorizationPolicyBuilder">Authorization policy builder.</param> /// <param name="requiredPrivileges">The required privileges.</param> /// <returns></returns> public static AuthorizationPolicyBuilder RequireAnyUserPrivileges(this AuthorizationPolicyBuilder authorizationPolicyBuilder, UserPrivileges requiredPrivileges) { return(authorizationPolicyBuilder.AddRequirements(new UserPrivilegeRequirement(requiredPrivileges, true))); }
public AnyUserPrivilegeAttribute(UserPrivileges privileges) { Policy = $"{AuthenticationStrings.UserPrivilegePolicyPrefix}-{(int)privileges}-{CookieAuthenticationDefaults.AuthenticationScheme}"; AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme; }
/// <summary> /// see if current user has sufficient access to specified object /// </summary> /// /// <param name="entity"> /// object to check for access to /// </param> /// /// <param name="requiredPrivileges"> /// required access level to specified entity /// </param> /// /// <returns> /// true if there is a match, false otherwise /// </returns> protected bool MatchUserPrivilege(IEntity entity, UserPrivileges requiredPrivileges) { return MatchUserPrivilege(GetCurrentUserPrivileges(entity), requiredPrivileges); }
/// <summary> /// Initialises a new instance of the <see cref="CreateUsersViewModel"/> class. /// </summary> public CreateUsersViewModel() { privileges = UserPrivileges.Default; ResetUserCommand = ReactiveCommand.Create(ResetUserCommandImpl); }
/// <summary> /// Returns whether the given privilege value contains specific privileges. /// </summary> /// <param name="p">Privilege value.</param> /// <param name="privileges">Specific privileges to check.</param> /// <returns></returns> public static bool HasPrivileges(this UserPrivileges p, UserPrivileges privileges) { return((p & privileges) == privileges); }
/// <summary> /// Returns whether the given privilege value contains any of the specified privileges. /// </summary> /// <param name="p">Privilege value.</param> /// <param name="privileges">Privileges to check.</param> /// <returns></returns> public static bool HasAnyPrivilege(this UserPrivileges p, UserPrivileges privileges) { return((p & privileges) != 0); }
/// <summary> /// Creates a new requirement for user privileges. /// </summary> /// <param name="requiredPrivileges">The required privileges bitfield.</param> /// <param name="any">Sets whether any privilege from <see cref="RequiredPrivileges"/> suffices (true), or whether all privileges must be met (false).</param> public UserPrivilegeRequirement(UserPrivileges requiredPrivileges, bool any) { RequiredPrivileges = requiredPrivileges; Any = any; }