Exemple #1
0
        // [AuthorizeRoles(ModuleLevel = "users")]
        public ActionResult Details()
        {
            UserModel user_m = new UserModel();

            DataLayer.users user = Ion_Auth.GetUser(User.Identity.Name);
            user_m.email        = user.email;
            user_m.display_name = user.display_name;
            user_m.username     = user.username;

            return(View(user_m));
        }
Exemple #2
0
        //
        // GET: /Admin/


        public AdminController(string section = "", string icon = "")
        {
            rekursosEntities db = new rekursosEntities();

            System.Web.HttpContext HttpContext = System.Web.HttpContext.Current;
            var type = this.GetType();

            ViewBag.Type = type;
            Dictionary <string, List <Menu> > MenuItems = new Dictionary <string, List <Menu> >();

            if (HttpContext.User.Identity.IsAuthenticated)
            {
                var User = Ion_Auth.GetUser(HttpContext.User.Identity.Name);
                ViewBag.UserCurrent = User;
                Dictionary <string, string[]> ListPermissions = PermissionModel.GetGroup((int)User.group_id);

                foreach (var module in db.modules.Where(w => w.menu != "0" && w.is_backend == 1).Where(w => w.installed == 1).ToList())
                {
                    if (ListPermissions.ContainsKey(module.slug) || User.groups.name == "admin")
                    {
                        if (MenuItems.ContainsKey(module.menu) == false)
                        {
                            MenuItems.Add(module.menu, new List <Menu>());
                        }
                        MenuItems[module.menu].Add(new Menu {
                            slug = module.slug, name = module.name
                        });
                    }
                }
            }


            Module ModuleDetails = new Module()
            {
                icon = "", description = "", name = ""
            };

            if (section != "")
            {
                var module = db.modules.Where(w => w.slug == section).SingleOrDefault();

                if (module != null)
                {
                    //ModuleDetails.ShortCuts = new List<ShortCuts>();
                    switch (module.slug)
                    {
                    /*case "viaticos":
                     *  ModuleDetails.icon = "ion-card";
                     *  break;
                     * case "comisiones":
                     *  ModuleDetails.icon = "ion-android-list";
                     *  break;
                     *
                     * case "empleados":
                     *  ModuleDetails.icon = "ion-ios-people";
                     *  break;
                     * case "settings":
                     *  ModuleDetails.icon = "ion-gear-b";
                     *  break;
                     * case "liquidaciones":
                     *  ModuleDetails.icon = "ion-cash";
                     *  break;*/
                    default:
                        //ModuleDetails.icon = icon;
                        break;
                    }
                    ModuleDetails.name        = module.name;
                    ModuleDetails.description = module.description;



                    ///ModuleDetails.ShortCuts.Add(new ShortCuts { Name = "Agregar localidad", Class = "btn btn-success", Uri = "localidades/Create" });
                }
                else
                {
                    ModuleDetails.icon        = "ion-help";
                    ModuleDetails.name        = "NA";
                    ModuleDetails.description = "Sin descripción del módulo.";
                }
            }
            ViewBag.MenuItems = MenuItems;

            ViewBag.ModuleDetails = ModuleDetails;
        }
Exemple #3
0
        public ActionResult Save(UserModel user_m, string tab = "profile")
        {
            users update = new users();
            users user   = Ion_Auth.GetUser(User.Identity.Name, false);

            update.id         = user.id;
            update.group_id   = user.group_id;
            update.password   = user.password;
            update.active     = user.active;
            update.created_on = user.created_on;
            update.last_login = user.last_login;
            update.username   = user.username;

            update.display_name = user.display_name;
            update.email        = user.email;


            switch (tab)
            {
            case "profile":

                update.email        = user_m.email;
                update.display_name = user_m.display_name;
                //update.password = user.password;
                break;

            case "password":
                if (user_m.old_password != "" && Sha1.SHA1HashStringForUTF8String(user_m.old_password) != user.password)
                {
                    ModelState.AddModelError("Error", "La antigua contraseña es inválida.");
                }
                if (user_m.new_password != user_m.retype_password)
                {
                    ModelState.AddModelError("Error1", "La nueva contraseña no coinciden.");
                }
                else
                {
                    update.password = Sha1.SHA1HashStringForUTF8String(user_m.new_password);
                }
                break;
            }
            if (ModelState.IsValid)
            {
                //user.groups = null;
                db.Entry(update).State = EntityState.Modified;
                db.SaveChanges();

                FlashData.SetFlashData("success", "Tu cuenta ha sido modificada satisfactoriamente");
            }
            else
            {
                string errors = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        errors += error.ErrorMessage + "\n";
                    }
                }

                if (errors != "")
                {
                    FlashData.SetFlashData("error", errors);
                }
            }
            return(RedirectToAction("Details"));
        }