示例#1
0
        /// <summary>
        /// Guardars the usuario.
        /// </summary>
        private void GuardarUsuario()
        {
            List<DTRol> listaRoles = new List<DTRol>();
            listaRoles.Add(new DTRol() { NombreCorto = ddlListRoles.SelectedValue, Nombre = ddlListRoles.SelectedItem.Text });

            DTSeguridad objDTSeguridad = new DTSeguridad { Usuario = { Nombre = lblUserName.Text.Trim(), ListaRoles = listaRoles, Aprobado = chkHabilitado.Checked } };
            objBLSeguridad = new BLSeguridad();
            objBLSeguridad.Data = objDTSeguridad;
            objBLSeguridad.ActualizarUsuario();

            //BuscarFiltrando();
            LimpiarCampos();

            udpRoles.Visible = false;
            udpRoles.Update();
        }
示例#2
0
        /// <summary>
        /// Handles the CreatedUser event of the RegisterUser control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            propSeguridad = new DTSeguridad();
            propSeguridad.Usuario.Nombre = RegisterUser.UserName.Trim();
            //Personal = 1,
            //Alumno = 2,
            //Tutor = 3
            DTRol rol = new DTRol();

            switch (propPersona.idTipoPersona)
            {
                case 1:
                    rol.Nombre = enumRoles.Administrativo.ToString();
                    break;
                case 2:
                    rol.Nombre = enumRoles.Alumno.ToString();
                    break;
                case 3:
                    rol.Nombre = enumRoles.Tutor.ToString();
                    break;
            }
            //asigna un rol por defecto, en función de la persona
            propSeguridad.Usuario.ListaRoles.Add(rol);
            propSeguridad.Usuario.Aprobado = true;
            propSeguridad.Usuario.EsUsuarioInicial = false;

            //encriptar la password
            propSeguridad.Usuario.PasswordNuevo = BLEncriptacion.Encrypt(RegisterUser.Password);
            propSeguridad.Usuario.Password = RegisterUser.Password;

            objBLSeguridad = new BLSeguridad(propSeguridad);
            objBLSeguridad.ActualizarUsuario();

            objBLSeguridad.CambiarPassword();

            //actualiza el nombre de usuario en la persona
            propPersona.username = propSeguridad.Usuario.Nombre;
            BLPersona objBLPersona = new BLPersona(propPersona);
            objBLPersona.Save();

            //loquea al usuario y lo redirecciona a la pagina de inicio de usuarios logueados
            Session.Abandon();
            FormsAuthentication.SignOut();
            FormsAuthentication.Initialize();
            FormsAuthentication.SetAuthCookie(propSeguridad.Usuario.Nombre, true /* createPersistentCookie */);
            ObjSessionDataUI.ObjDTUsuario = propSeguridad.Usuario;

            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (string.IsNullOrEmpty(continueUrl))
                continueUrl = "~/Private/Account/Welcome.aspx";
            Response.Redirect(continueUrl, false);
        }