public async Task <ActionResult> SetPassword(SetPasswordViewModel model) { if (Session["usuario"] == null) { return(RedirectToAction("Index", "Usuarios")); } if (ModelState.IsValid) { var usuario = Session["usuario"] as User; var IdUsuario = usuario.ss_id_usr.ToString(); //ELIMINA EL PASSWORD PARA SER SETEADO pcUpmeCnx dbUsr = new pcUpmeCnx(); dbUsr.Database.ExecuteSqlCommand("UPDATE MUB_USUARIOS SET PWDHASH = NULL WHERE ID_USUARIO = :ID_USR", new[] { new OracleParameter("ID_USR", IdUsuario) }); //CAMBIA EL PASSWORD var result = await UserManager.AddPasswordAsync(IdUsuario, model.NewPassword); if (result.Succeeded) { return(RedirectToAction("Index", "Usuarios")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
// // GET: /Manage/Index public async Task <ActionResult> Index(ManageMessageId?message) { ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Su Clave ha sido Cambiada exitosamente." : message == ManageMessageId.SetPasswordSuccess ? "Su clave ha sido definida." : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." : message == ManageMessageId.Error ? "ADVERTENCIA! Ha ocurrido un error al cambiar la Clave." : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : ""; var userId = User.Identity.GetUserId(); var model = new IndexViewModel { HasPassword = HasPassword(), //PhoneNumber = await UserManager.GetPhoneNumberAsync(userId), //TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId), //Logins = await UserManager.GetLoginsAsync(userId), BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId) }; pcUpmeCnx dbUsr = new pcUpmeCnx(); long idusr = Convert.ToInt32(GlobalVariables.idUsuario); long idModulo = Convert.ToInt32(GlobalVariables.idModulo); var tmp = dbUsr.MUB_USUARIOS_ROLES.Where(u => u.ID_USUARIO == idusr).Include(m => m.MUB_ROL).Where(r => r.MUB_ROL.ID_MODULO == idModulo).Include(d => d.MUB_ROL.MUB_MODULOS).Include(u => u.MUB_USUARIOS).Include(u => u.MUB_USUARIOS.MUB_ORGANIZACIONES); foreach (var item in tmp) { string nom_Usuario = item.MUB_USUARIOS.NOMBRE.ToString(); @ViewBag.Nombre = nom_Usuario; string nom_Organizacion = item.MUB_USUARIOS.MUB_ORGANIZACIONES.RAZON_SOCIAL.ToString(); @ViewBag.Organizacion = nom_Organizacion; string nom_rol = item.MUB_ROL.NOMBRE.ToString(); @ViewBag.Perfil = nom_rol; } @ViewBag.Usuario = User.Identity.Name.ToString(); //@ViewBag.Perfil; return(View(model)); }
public static Boolean Acceso(string rol) { //var tmp = dbUsr.MUB_USUARIOS_ROLES.Include(m => m.sdf).Where(u => u.ID_USUARIO == Convert.ToInt32(idUsuario)); // //var date = new Class().GetFirstInMonth(DateTime dt); pcUpmeCnx dbUsr = new pcUpmeCnx(); bool ok = false; long idusr = Convert.ToInt32(idUsuario); var tmp = dbUsr.MUB_USUARIOS_ROLES.Where(u => u.ID_USUARIO == idusr).Include(m => m.MUB_ROL).Where(r => r.MUB_ROL.ID_MODULO == idModulo).Include(d => d.MUB_ROL.MUB_MODULOS); foreach (var item in tmp) { string nom_rol = item.MUB_ROL.NOMBRE.ToString(); if (rol == nom_rol) { ok = true; } } return(ok); }