/// <summary> /// Returns true if UserSubmit instances are equal /// </summary> /// <param name="other">Instance of UserSubmit to be compared</param> /// <returns>Boolean</returns> public bool Equals(UserSubmit other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Uuid == other.Uuid || Uuid != null && Uuid.Equals(other.Uuid) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( Surname == other.Surname || Surname != null && Surname.Equals(other.Surname) ) && ( Username == other.Username || Username != null && Username.Equals(other.Username) ) && ( Password == other.Password || Password != null && Password.Equals(other.Password) ) && ( Email == other.Email || Email != null && Email.Equals(other.Email) ) && ( PhoneNumber == other.PhoneNumber || PhoneNumber != null && PhoneNumber.Equals(other.PhoneNumber) ) && ( Avatar == other.Avatar || Avatar != null && Avatar.Equals(other.Avatar) ) && ( LdapAuthenticationModeId == other.LdapAuthenticationModeId || LdapAuthenticationModeId != null && LdapAuthenticationModeId.Equals(other.LdapAuthenticationModeId) ) && ( RoleIds == other.RoleIds || RoleIds != null && other.RoleIds != null && RoleIds.SequenceEqual(other.RoleIds) ) && ( TeamIds == other.TeamIds || TeamIds != null && other.TeamIds != null && TeamIds.SequenceEqual(other.TeamIds) )); }
/// <summary> /// 判断用户是否属于某个角色ID /// </summary> /// <param name="roleId"></param> /// <returns></returns> public bool IsInRoleId(string roleId) { return(RoleIds.Contains(roleId)); }
public RoleFilter(int id) { RoleIds.Add(id); }
public RoleFilter(IEnumerable <int> ids) { RoleIds.AddRange(ids); }
public RolePermissionFilter(IEnumerable <int> ids) { RoleIds.AddRange(ids); }
public RolePermissionFilter(int id) { RoleIds.Add(id); }
public JsonResult Login(Login LoginModel) { JsonResponse <string> Response = new JsonResponse <string>(); try { var EncryptPassword = Common.Common.Encrypt(LoginModel.Password); var UserDetail = _db.Users.Where(u => u.UserName == LoginModel.UserName && u.Password == EncryptPassword).FirstOrDefault(); //var UserDetail = _db.Users.Where(u => u.LoginId == LoginModel.UserName).FirstOrDefault(); if (UserDetail == null) { Response.IsError = true; Response.Message = "User not found"; return(Json(Response, JsonRequestBehavior.AllowGet)); } var DecryptPassword = Common.Common.Decrypt(UserDetail.Password); if (UserDetail != null) { ApplicationSession.Current.IsLoggedIn = true; ApplicationSession.Current.SessionID = System.Web.HttpContext.Current.Session.SessionID; ApplicationSession.Current.UserID = UserDetail.Id; var LoginUserRoles = _db.UserInRoles.Where(ur => ur.UserId == UserDetail.Id).ToList(); if (LoginUserRoles.Count() > 0) { foreach (var item in LoginUserRoles) { RoleIds role = new RoleIds(); role.id = item.Id; role.name = item.UserRole != null ? item.UserRole.Role : ""; if (UserRoles.Admin == (UserRoles)item.Id) { ApplicationSession.Current.IsSuperAdmin = true; } ApplicationSession.Current.RoleIDs.Add(role); } } else { Response.IsError = true; Response.Message = "User not found"; return(Json(Response, JsonRequestBehavior.AllowGet)); } //if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") // && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) //{ // return Json(, JsonRequestBehavior.AllowGet); //} Response.IsError = false; return(Json(Response, JsonRequestBehavior.AllowGet)); } else { Response.IsError = true; Response.Message = "User id or password is wrong"; return(Json(Response, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { Response.IsError = true; Response.Message = ex.Message != null ? ex.Message : ex.InnerException.Message; return(Json(Response, JsonRequestBehavior.AllowGet)); } }
public bool HasRoles(params UserRoleId[] roleIds) { return(RoleIds.Any(roleIds.Contains)); }
public bool HasRole(UserRoleId roleId) { return(RoleIds.Contains(roleId)); }