//[Authorize(Roles = "Admin,SuperAdmin")] // GET: Device/Details/5 public ActionResult Details(int did) { if (BaseUser != null) { if (BaseUser.IsInRole("Admin") || BaseUser.IsInRole("SuperAdmin")) { var d = DataAccess.LoadItemById(did); var model = new Device { DeviceID = d.DeviceID, Name = d.Name, RoomAsigned = d.RoomAsigned, AssignedOn = d.AssignedOn, ReportedOn = d.ReportedOn, RoomNr = d.RoomNr }; return(View("~/views/device/_details.cshtml", model)); } return(View("~/views/shared/Error.cshtml")); } else { return(View("~/views/shared/Error.cshtml")); } }
public ActionResult Details(UserModel model) { if (BaseUser != null && BaseUser.IsInRole("SuperAdmin")) { var x = GetUser(model.Email); if (x != null) { model = new UserModel { FirstName = x.FirstName, LastName = x.LastName, IsAdmin = x.IsAdmin, Email = x.Email, IsSuperAdmin = x.IsSuperAdmin, Password = x.Password }; return(View(model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
/// <summary> /// 新增 /// </summary> /// <param name="sender">控件</param> /// <param name="e">参数</param> private void toolbarAdd_Click(object sender, EventArgs e) { var dtDoctorPost = cboDoctorPost.DataSource as DataTable; var strDoctorPost = string.Empty; if (null != dtDoctorPost && dtDoctorPost.Rows.Count > 0) { strDoctorPost = dtDoctorPost.Rows[0]["Code"] + string.Empty; } var dtNursePost = cboDoctorPost.DataSource as DataTable; var strNursePost = string.Empty; if (null != dtNursePost && dtNursePost.Rows.Count > 0) { strNursePost = dtNursePost.Rows[0]["Code"] + string.Empty; } CurrentUser = new BaseUser { DoctorPost = strDoctorPost, NursePost = strNursePost }; tbCode.Enabled = true; cboUserName.Enabled = true; dgUser.Enabled = false; toolbarAdd.Enabled = false; toolbarFlag.Enabled = false; toolbarRel.Enabled = false; barUser.Refresh(); tbCode.Focus(); }
new public ActionResult Profile() { BaseUser model = db.BaseUsers.Find(WebSecurity.CurrentUserId); model.password = Permission.defaultShowPassword; return(PartialView(model)); }
public void AlterUser(int empid, int userid) { Action <ClientRequestData> requestAction = ((ClientRequestData request) => { request.AddData(empid); request.AddData(userid); }); ServiceResponseData retdata = InvokeWcfService("MainFrame.Service", "EmpUserController", "AlterUser", requestAction); BaseEmployee _currEmp = retdata.GetData <BaseEmployee>(0); int currDeptId = retdata.GetData <int>(1); BaseUser _currUser = retdata.GetData <BaseUser>(2); List <BaseGroup> _grouplist = retdata.GetData <List <BaseGroup> >(3); List <BaseDept> _deptlist = retdata.GetData <List <BaseDept> >(4); List <BaseGroup> _usergroup = retdata.GetData <List <BaseGroup> >(5); List <BaseDept> _empdept = retdata.GetData <List <BaseDept> >(6); BaseDept currdept = retdata.GetData <BaseDept>(7); ((IfrmAddUser)iBaseView["frmAddUser"]).loadAddUserView(_currEmp, currDeptId, _currUser, _grouplist, _deptlist, _usergroup, _empdept); (iBaseView["frmAddUser"] as Form).Text = "修改用户"; (iBaseView["frmAddUser"] as Form).ShowDialog(); }
public Oats(BaseUser user, BaseServer server, BaseChannel channel, BaseMessage message) { if (message.GetText().ToLower().IndexOf("oats") != -1 || message.GetText().ToLower().IndexOf("öats") != -1) { channel.SendMessage("pass me the öats brother\nhttps://www.youtube.com/watch?v=8I1sQlRiJdY"); } }
public async Task <IHttpActionResult> PutBaseUser(int id, BaseUser baseUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != baseUser.Id) { return(BadRequest()); } db.Entry(baseUser).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BaseUserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ServiceResponseData AlterUser() { int empid = requestData.GetData <int>(0); int userid = requestData.GetData <int>(1); BaseEmployee currEmp = (BaseEmployee)NewObject <BaseEmployee>().getmodel(empid); BaseUser currUser = (BaseUser)NewObject <BaseUser>().getmodel(userid); List <BaseGroup> grouplist = NewObject <BaseGroup>().getlist <BaseGroup>(); List <BaseDept> deptlist = NewObject <BaseDept>().getlist <BaseDept>(); List <BaseGroup> usergroup = NewObject <Group>().GetGroupList(userid); List <BaseDept> empdept = NewObject <Dept>().GetHaveDept(empid); BaseDept currdept = NewObject <Dept>().GetDefaultDept(empid); responseData.AddData(currEmp); responseData.AddData(currdept == null ? -1 : currdept.DeptId); responseData.AddData(currUser); responseData.AddData(grouplist); responseData.AddData(deptlist); responseData.AddData(usergroup); responseData.AddData(empdept); responseData.AddData(currdept); return(responseData); }
/// <summary> /// 实现对权限的删除 /// </summary> /// <param name="permissionInfo">权限的实体类</param> /// <returns>返回执行成功的标志</returns> public ActionResult UpdatePermissionInfo(BasePermission permissionInfo) { var editPermissionInfo = _permissionInfoService.LoadEntities(c => c.ID == permissionInfo.ID).FirstOrDefault(); if (editPermissionInfo == null) { return(Content("请您检查,错误信息")); } editPermissionInfo.PerMission = permissionInfo.PerMission; editPermissionInfo.RequestHttpType = permissionInfo.RequestHttpType; editPermissionInfo.RequestURL = permissionInfo.RequestURL; editPermissionInfo.ActionType = permissionInfo.ActionType; editPermissionInfo.SortCode = permissionInfo.SortCode; editPermissionInfo.AllowDelete = permissionInfo.AllowDelete; editPermissionInfo.AllowEdit = permissionInfo.AllowEdit; editPermissionInfo.IsVisible = permissionInfo.IsVisible; editPermissionInfo.Enabled = permissionInfo.Enabled; editPermissionInfo.Description = permissionInfo.Description; editPermissionInfo.ModifiedOn = DateTime.Parse(DateTime.Now.ToString()); BaseUser user = Session["UserInfo"] as BaseUser; editPermissionInfo.ModifiedUserID = user.Code; //获取修改信息的ID editPermissionInfo.ModifiedBy = user.UserName; //获取修改此用户的用户名 if (_permissionInfoService.UpdateEntity() > 0) { return(Content("OK")); } return(Content("Error")); }
/// <summary> /// 新增后台管理用户 /// </summary> /// <param name="info"></param> /// <returns></returns> public int InsertBaseUser(BaseUser info) { Dictionary <string, object> keyValuePairs = info.ToDictionary(); keyValuePairs.Remove("ID"); return(aideIBaseUser.Insert(keyValuePairs)); }
public ActionResult needPassword(FormCollection form) { BaseUser user = Helper.GetUser(db); BaseUserAction action = user.getOneBaseUserAction(user.tryAction, user.tryController); if (action != null) { if (form["password"] != null) { string password = Permission.CalculateMD5Hash(form["password"]); if (action.password.ToUpper() == password.ToString()) { BaseUserAction Baction = db.BaseUserActions.FirstOrDefault(d => d.actionID == action.actionID && d.userID == user.ID); if (Baction != null) { Baction.leftSeconds = 1; db.SaveChanges(); } return(Redirect(URLHelper.getUrl(user.tryController, user.tryAction))); } else { GlobalsViewBag.Add("error", "Contraseña Incorrecta."); return(Redirect(URLHelper.getCurrentUrl(this.ControllerContext))); } } } else { return(Redirect(URLHelper.getCurrentUrl(this.ControllerContext))); } return(Redirect(URLHelper.getCurrentUrl(this.ControllerContext))); }
/// <summary> /// 获取Action处理的输出字节流 /// </summary> /// <returns></returns> public static byte[] GetActionResponse(int actionId, BaseUser baseUser, string parameters, out HttpGet httpGet) { string serverHost = string.Format("{0}:{1}", ActionConfig.Current.IpAddress, ActionConfig.Current.Port); string param = string.Format("MsgId={0}&St={1}&Sid={2}&Uid={3}&ActionID={4}{5}", 0, "st", baseUser.GetSessionId(), baseUser.GetUserId(), actionId, parameters); httpGet = new HttpGet(param, baseUser.SocketSid, baseUser.RemoteAddress); BaseStruct baseStruct = FindRoute(ActionConfig.Current.TypeName, httpGet, actionId); SocketGameResponse response = new SocketGameResponse(); baseStruct.UserFactory = uid => { return(baseUser); }; baseStruct.SetPush(); baseStruct.DoInit(); using (baseStruct.RequestLock()) { if (!baseStruct.GetError() && baseStruct.ReadUrlElement() && baseStruct.DoAction() && !baseStruct.GetError()) { baseStruct.BuildPacket(); baseStruct.WriteAction(response); } else { baseStruct.WriteErrorAction(response); } } return(response.ReadByte()); }
public ActionResult Edit(Device device) { try { if (BaseUser != null) { if (BaseUser.IsInRole("Admin") || BaseUser.IsInRole("SuperAdmin")) { // TODO: Add update logic here //int iD, string name, bool roomAsigned, int roomNr, DateTime reportedOn, DateTime assignedOn var x = DataAccess.EditItem(device.DeviceID, device.Name, device.RoomAsigned, device.RoomNr, device.ReportedOn, device.AssignedOn); return(RedirectToAction("List", "Device")); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } } catch { return(View()); } }
public ActionResult Edit(int did) { if (BaseUser != null) { if (BaseUser.IsInRole("Admin") || BaseUser.IsInRole("SuperAdmin")) { var x = DataAccess.LoadItemById(did); var model = new Device() { DeviceID = x.DeviceID, Name = x.Name, AssignedOn = x.AssignedOn, ReportedOn = x.ReportedOn, RoomAsigned = x.RoomAsigned, RoomNr = x.RoomNr }; return(View("~/views/device/Edit.cshtml", model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
public void CheckDiscountPolicyWithoutUpdate(ShoppingBag bag, Guid shopGuid) { var cart = bag.GetShoppingCartAndCreateIfNeededForGuestOnlyOrInBagDomain(shopGuid); Shop shop = _unitOfWork.ShopRepository.FindByIdOrNull(shopGuid); BaseUser user = _unitOfWork.BaseUserRepository.FindByIdOrNull(bag.UserGuid); //Copy the list so you can iterate and add the discount to it ICollection <Tuple <ShopProduct, int> > tempPurchasedProducts = new List <Tuple <ShopProduct, int> >(); foreach (Tuple <ShopProduct, int> record in cart.PurchasedProducts) { tempPurchasedProducts.Add(record); } foreach (IDiscountPolicy policy in shop.DiscountPolicies) { bool alreadyAddedDiscount = false; foreach (Tuple <ShopProduct, int> record in tempPurchasedProducts) { var discountProductAndQuantity = policy.ApplyPolicy(cart, record.Item1.Guid, record.Item2, user, _unitOfWork); if (discountProductAndQuantity != null && !alreadyAddedDiscount) { cart.AddProductToCart(discountProductAndQuantity.Item1, discountProductAndQuantity.Item2); alreadyAddedDiscount = true; } } } }
public async Task UpdateBaseUser([ApiVal(Val.FormMode)] BaseUser info) { AjaxJson _ajv = new(); if (info != null) { if (!string.IsNullOrWhiteSpace(info.BasePwd)) { if (info.BasePwd.Contains("null")) { info.BasePwd = null; } else { info.BasePwd = info.BasePwd.MD5Upper(); } } if (FacadeManage.AideAdminFacade.UpdateBaseUser(info) > 0) { //加入操作日志 AddBaseLog(mvc, info.ToJson()); _ajv.code = 0; _ajv.msg = "修改成功!"; } } else { _ajv.code = 100; _ajv.msg = "对象为空!"; } await JsonAsync(_ajv); }
public IActionResult Subject(int id) { Subject subject = db.Subjects.FirstOrDefault(u => u.Id == id); BaseUser teacher = db.Users.FirstOrDefault(u => u.Id == subject.TeacherId); Response.Cookies.Append("subjectId", Convert.ToString(id)); ViewBag.subject = subject; ViewBag.teacherName = teacher.FirstName + " " + teacher.LastName; int currentUserId = 0; if (Request.Cookies["Id"] != null) { currentUserId = Convert.ToInt32(Request.Cookies["Id"]); } if (subject.TeacherId == currentUserId) { List <SubjectSummaryModel> subjectSummary = subjectHelper.GetSummaryForSubject(id); ViewBag.subjectSummary = subjectSummary; return(View("~/Views/Subject/TeacherSubject.cshtml")); } else { List <StudentSubjectSummary> subjectSummary = subjectHelper.GetSummaryForStudentAndSubject(currentUserId, id); ViewBag.subjectSummary = subjectSummary; return(View("~/Views/Subject/StudentSubject.cshtml")); } }
public static void Initialize(WorkDataContext context) { context.Database.EnsureCreated(); if (context.BaseRoles.Any()) { return; } var baseUser = new BaseUser { Id = Guid.NewGuid().ToString(), IsDelete = false, UserName = "******", UserRoles = new List <UserRole> { new UserRole { BaseRole = new BaseRole { Id = Guid.NewGuid().ToString(), RoleName = "超级管理员", Code = "administrator" } } } }; baseUser.Password = new PasswordHasher <BaseUser>().HashPassword(baseUser, "password"); context.BaseUsers.Add(baseUser); context.SaveChanges(); }
public async Task <IActionResult> Register(RegisterViewModel vm) { if (ModelState.IsValid) { var user = new BaseUser { Email = vm.Email, UserName = vm.Email, DateOfBirth = DateTime.Now, Age = new Random().Next(16, 69), FirstName = vm.FirstName, LastName = vm.LastName }; var result = await _userManager.CreateAsync(user, vm.Password); if (result.Succeeded) { await _signInManager.SignInAsync(user, false); return(RedirectToAction("Index", "MemberHome")); } else { foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } } return(View(vm)); }
public ActionResult ChangePassword(FormCollection frm) { int UserID = Convert.ToInt32(Session["UserID"]); string ViewOldPassword = frm.Get("OldPassword"); var Query = _db.Users.Where(x => x.BaseUserID == UserID && x.Password == ViewOldPassword); if (Query.Count() > 0) { string ViewNewPassword = frm.Get("NewPassword"); string ViewNewPasswordAgain = frm.Get("NewPasswordAgain"); if (ViewNewPassword == ViewNewPasswordAgain) { BaseUser ToEdit = _db.Users.FirstOrDefault(x => x.BaseUserID == UserID); ToEdit.Password = ViewNewPassword; if (_db.SaveChanges() > 0) { return(RedirectToAction("SuccessPage", "Admin")); } else { ViewBag.Mesaj = "Eski Şifreniz İle Yeni Şifreniz Aynı Olmamalı"; } } else { ViewBag.Mesaj = "Yeni Şifreleriniz Uyuşmuyor"; } } else { ViewBag.Mesaj = "Eski Şifreniz Hatalı"; } return(View()); }
public JsonResult Delete(int id = 0) { BaseUser model = db.BaseUsers.Find(id); foreach (var item in model.BaseUserMenus.ToList()) { db.BaseUserMenus.Remove(item); } foreach (var item in model.BaseUserActions.ToList()) { db.BaseUserActions.Remove(item); } foreach (var item in model.BaseWidgets.ToList()) { db.BaseWidgets.Remove(item); } model.BaseProfiles.Clear(); db.BaseUsers.Remove(model); db.SaveChanges(); BoolString validation = model.AfterDelete(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } return(Json("ok", JsonRequestBehavior.AllowGet)); }
public void LoadFromAppSettings() { var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; var composite = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["_userSessionData"]; if (composite == null) { return; } Username = (string)composite["Username"]; Password = (string)composite["Password"]; RankToken = (string)composite["RankToken"]; FacebookUserId = (string)composite["FacebookUserId"]; FacebookAccessToken = (string)composite["FacebookAccessToken"]; LoggedInUser = new BaseUser { IsVerified = (bool)composite["LoggedInUser.IsVerified"], IsPrivate = (bool)composite["LoggedInUser.IsPrivate"], Pk = (long)composite["LoggedInUser.Pk"], ProfilePictureUrl = new Uri((string)composite["LoggedInUser.ProfilePictureUrl"]), ProfilePictureId = (string)composite["LoggedInUser.ProfilePictureId"], Username = (string)composite["LoggedInUser.Username"], FullName = (string)composite["LoggedInUser.FullName"] }; }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } BeneficiaryCodes checkBc = _context.BeneficiaryCodes.FirstOrDefault(cbc => (cbc.BeneficiaryCodesId == InputBeneficiary.BeneficiaryId)); if (checkBc == null) { ModelState.AddModelError("FailedbcCheck", "Invalid Beneficiary Code!"); return(Page()); } _context.Add(InputBeneficiary); BaseUser user = new BaseUser { UserName = InputBeneficiary.BeneficiaryId, Email = InputBeneficiary.EmailAddress, Role = "Beneficiary", Icon = icon }; var result = await _userManager.CreateAsync(user, "Password0)"); await _context.SaveChangesAsync(); BaseUser currentUser = await _userManager.FindByNameAsync(InputBeneficiary.BeneficiaryId); await _signInManager.SignInAsync(currentUser, isPersistent : false); return(RedirectToPage("/Index")); }
/// <summary> /// 实现对菜单项的删除 /// </summary> /// <param name="permissionInfo">菜单项的实体类</param> /// <returns>返回执行成功的标志</returns> public ActionResult UpdatePermissionGroup(BasePermissionGroup permissionGroup) { var editPermissionGroupInfo = _permissionGroupService.LoadEntities(c => c.ID == permissionGroup.ID).FirstOrDefault(); if (editPermissionGroupInfo == null) { return(Content("请您检查,错误信息")); } editPermissionGroupInfo.GroupName = permissionGroup.GroupName; editPermissionGroupInfo.GroupType = permissionGroup.GroupType; editPermissionGroupInfo.SortCode = permissionGroup.SortCode; editPermissionGroupInfo.AllowDelete = permissionGroup.AllowDelete; editPermissionGroupInfo.AllowEdit = permissionGroup.AllowEdit; editPermissionGroupInfo.IsVisible = permissionGroup.IsVisible; editPermissionGroupInfo.Enabled = permissionGroup.Enabled; editPermissionGroupInfo.Description = permissionGroup.Description; editPermissionGroupInfo.ModifiedOn = DateTime.Parse(DateTime.Now.ToString()); BaseUser user = Session["UserInfo"] as BaseUser; editPermissionGroupInfo.ModifiedUserID = user.Code; editPermissionGroupInfo.ModifiedBy = user.UserName; if (_permissionGroupService.UpdateEntity() > 0) { return(Content("OK")); } return(Content("Error")); }
public ActionResult Details(string email) { if (email.Contains("%40")) { email = email.Replace("%40", "@"); } if (BaseUser != null && BaseUser.IsInRole("SuperAdmin")) { var x = GetUser(email); var model = new UserModel { FirstName = x.FirstName, LastName = x.LastName, IsAdmin = x.IsAdmin, Email = x.Email, IsSuperAdmin = x.IsSuperAdmin, Password = x.Password }; if (BaseUser != null && BaseUser.IsInRole("SuperAdmin")) { return(View("~/views/user/Details.cshtml", model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
public async Task <CreateEventViewModel> Handle(CreateEventCommand request, CancellationToken cancellationToken) { var userId = HttpContextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier); BaseUser user = _context.BaseUsers.FirstOrDefault(u => u.Id == userId); if (user == null) { throw new CustomException(new Error { ErrorType = ErrorType.Unauthorized, Message = Localizer["Unauthorized"] }); } var eventObj = new Domain.Models.Event() { EventName = request.EventName, EventDescription = request.EventDescription, EventTime = request.EventTime, User = user, UserId = user.Id }; await _context.Events.AddAsync(eventObj, cancellationToken); await _context.SaveChangesAsync(cancellationToken); return(new CreateEventViewModel { EventDto = _mapper.Map <EventShortDto>(eventObj) }); }
// GET: User public ActionResult List() { if (BaseUser != null && !BaseUser.IsInRole("Default") && !BaseUser.IsInRole("Admin")) { var d = GetAllUsers(); var model = new List <UserModel>(); foreach (var x in d) { model.Add(new UserModel { FirstName = x.FirstName, LastName = x.LastName, IsAdmin = x.IsAdmin, Email = x.Email, IsSuperAdmin = x.IsSuperAdmin, Password = x.Password }); } if (model.Count > 0) { return(View(model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
public BaseUser GetDataUser(string username) { Connect(); BaseUser user = new BaseUser();; var command = connection.CreateCommand(); command.CommandText = "SELECT * FROM librarycatalog.users WHERE username=@username"; command.Parameters.AddWithValue("@username", username); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { user.ID = (int)reader["id"]; user.Username = (string)reader["username"]; user.Name = (string)reader["firstName"]; user.LastName = (string)reader["lastName"]; user.Password = (string)reader["password"]; user.DateRegistred = (string)reader["registredDate"]; user.Role = (int)reader["userRole"]; user.IsLoggedIn = true; } return(user); }
public async Task <Unit> Handle(ChangePasswordCommand request, CancellationToken cancellationToken) { var userId = HttpContextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier); BaseUser user = await UserManager.FindByIdAsync(userId); if (user == null) { throw new CustomException(new Error { ErrorType = ErrorType.Unauthorized, Message = Localizer["Unauthorized"] }); } if (UserManager.PasswordHasher.VerifyHashedPassword(user, user.PasswordHash, request.OldPassword) == PasswordVerificationResult.Failed) { throw new CustomException(new Error { ErrorType = ErrorType.InvalidPassword, Message = Localizer["InvalidPassword"] }); } await UserManager.ChangePasswordAsync(user, request.OldPassword, request.NewPassword); await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
//public static bool IsUserOnline(Microsoft.AspNetCore.Http.ISession session) => session.TryGetValue("Admin", out _); public static void Login(ISession session, BaseUser userTicket) { if (session != null && userTicket != null) { session.Set("Admin", userTicket); var RoleDirID = FacadeManage.AideAdminFacade.GetBaseUserInformation(userTicket.BaseRankId); if (RoleDirID.Success) { var data = RoleDirID.EntityList[0].ToVar <DataSet>(); var menu = PermissionsMenu.Menu.GetMenus(data, out List <Rout> routs, true); session.Set("Routs", routs); session.Set("Menu", menu); bool isedit = false; if (Rout.Contains(routs, "ManageList", out Rout rout)) { isedit = Rout.IsActionEnum(ActionEnum.Add | ActionEnum.Edit, rout.PermissionType);//ManageEdit } session.Set("UserInfo", new PermissionsMenu.UserInfo() { Token = session.Id, Id = userTicket.ID, Name = userTicket.BaseName, IsEdit = isedit, TokenUrl = Tool.Utils.AppSettings.Get("ServerUrl") }); } RoleAction.Session.Set(userTicket.BaseName.ToLower(), session.Id); } }