示例#1
0
        // GET: Profile
        public ActionResult Index()
        {
            sql3283190Context context = HttpContext.RequestServices.GetService(typeof(sql3283190Context)) as sql3283190Context;

            HomeController.FormInicialFlag = true;
            return(View(context.ObtenerPersona(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value)));

            //return View();
        }
示例#2
0
        public ActionResult Edit(string command, ProfileModel profileModel, int id, IFormCollection collection)
        {
            sql3283190Context context = HttpContext.RequestServices.GetService(typeof(sql3283190Context)) as sql3283190Context;
            string            correo  = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value;

            try
            {
                if (command == "submit")
                {
                    context.EditarUsuario(profileModel.Name, profileModel.FirstLastName, profileModel.SecondLastName, profileModel.PhoneNumber, correo);
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
示例#3
0
        public async Task <IActionResult> Index()
        {
            // If the user is authenticated, then this is how you can get the access_token and id_token
            if (User.Identity.IsAuthenticated)
            {
                string accessToken = await HttpContext.GetTokenAsync("access_token");

                // if you need to check the access token expiration time, use this value
                // provided on the authorization response and stored.
                // do not attempt to inspect/decode the access token
                DateTime accessTokenExpiresAt = DateTime.Parse(
                    await HttpContext.GetTokenAsync("expires_at"),
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.RoundtripKind);

                string idToken = await HttpContext.GetTokenAsync("id_token");

                // Now you can use them. For more info on when and how to use the
                // access_token and id_token, see https://auth0.com/docs/tokens


                // HECHO POR MACHO


                sql3283190Context context = HttpContext.RequestServices.GetService(typeof(sql3283190Context)) as sql3283190Context;

                // aqui lo que hago es asegurarme que si el usuario audentificado esta en la base sino para meterlo
                if (context.BuscarPersonaCorreoValidar(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value) == false)
                {
                    //  amodar esta verga abajo
                    // context.InsertarUsuarioPrimeraVez(User.Identity.Name, User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value, User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.MobilePhone)?.Value); // este metodo lo que hace es insertar por primera ves en la base
                    FormInicialFlag = false;

                    return(RedirectToAction("FORMINICIAL", "Profile"));

                    // no borrar
                }
            }
            FormInicialFlag = true;
            return(View());
        }