public async Task <dynamic> ChangePassword(string password, string oldPassword) { SEC_User objUser = new SEC_User(); action = "changePassword"; objUser.SetBy = UserID; objUser.UserID = UserID; objUser.ModifiedBy = UserID; objUser.UserName = StringEncription.Encrypt(oldPassword.Trim(), true); objUser.UserPassword = StringEncription.Encrypt(password.Trim(), true); respStatus = await Task.Run(() => _userService.AddUser(objUser, action, out outStatus)); return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); }
public async Task <dynamic> UpdateUser(SEC_User objUser) { if (ModelState.IsValid) { action = "edit"; objUser.SetBy = UserID; objUser.ModifiedBy = objUser.SetBy; objUser.UserPassword = StringEncription.Encrypt(objUser.UserPassword, true); respStatus = await Task.Run(() => _userService.AddUser(objUser, action, out outStatus)); // Error handling. return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); } else { respStatus = new ValidationResult("E404", _localizationService.GetResource("E404")); } return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); }
public static string Encrypt(string TextToBeEncrypted) { return(StringEncription.Encrypt(TextToBeEncrypted, Key)); }
public async Task <string> SetAuthorization(string user, string password, string isRemeber) { List <GetUserAccessPermission_Result> permissionMenu = null; string returnUrl = ViewBag.ReturnUrl == null ? "/SecurityModule/Account/Dashboard" : ViewBag.ReturnUrl; if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password)) { return(""); } bool result = await Task.Run(() => _userService.IsValidUser(StringEncription.RemoveSpecialCharacters(user.Trim()), StringEncription.Encrypt(password.Trim(), true), Convert.ToString(GetIPAddress.LocalIPAddress()), out permissionMenu)); if (result) { var ident = new ClaimsIdentity( new[] { // adding following 2 claim just for supporting default antiforgery provider //new Claim(ClaimTypes.NameIdentifier, permissionMenu[0].UserName), // optionally you could add roles if any new Claim(ClaimTypes.Role, permissionMenu[0].RoleTitle) //new Claim("RoleID",permissionMenu[0].RoleID) //new Claim("OwnerLevelID",permissionMenu[0].OwnerLevelID), //new Claim("OwnerID",permissionMenu[0].OwnerLevelID), //new Claim("OwnerName",permissionMenu[0].OwnerName), //new Claim("DefaultServer",permissionMenu[0].DefaultServer), //new Claim("UserID",permissionMenu[0].UserID) }, DefaultAuthenticationTypes.ApplicationCookie); Session["UserID"] = (from temp in permissionMenu where temp.UserID != "" select temp.UserID).FirstOrDefault(); // permissionMenu[0].UserID.ToString().Trim(); Session["User"] = (from temp in permissionMenu where temp.UserName != "" select temp.UserName).FirstOrDefault(); Session["OwnerLevelID"] = (from temp in permissionMenu where temp.OwnerLevelID != "" select temp.OwnerLevelID).FirstOrDefault(); Session["OwnerID"] = (from temp in permissionMenu where temp.OwnerID != "" select temp.OwnerID).FirstOrDefault(); //Session["DefaultServer"] = (from temp in permissionMenu where temp.DefaultServer != "" select temp.DefaultServer).FirstOrDefault(); Session["SEC_Menu"] = (from temp in permissionMenu[0].AccessMenu select new SEC_Menu { MenuID = temp.MenuID, MenuTitle = temp.MenuTitle, ParentMenuID = temp.ParentMenuID, ParentMenu = temp.ParentMenu, MenuUrl = temp.MenuUrl, MenuIcon = temp.MenuIcon, MenuOrder = temp.MenuOrder, PermissionClass = temp.PermissionClass }).ToList(); HttpContext.GetOwinContext().Authentication.SignIn( new AuthenticationProperties { IsPersistent = false }, ident); } else { return("E401"); } return(returnUrl); }