Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GenerarToken idioma  = new GenerarToken(Session["idioma"].ToString());
        string       ltitulo = L_Recuperar_Clave.ID;
        string       ldigite = L_User_Name.ID;
        string       lboton  = B_Recuperar.ID;

        idioma.paraIdioma(Session["idioma"].ToString(), CONSTANTE, ltitulo, ldigite, lboton);
        L_Recuperar_Clave.Text = idioma.Get_LTitulo();
        L_User_Name.Text       = idioma.Get_LDigite();
        B_Recuperar.Text       = idioma.Get_LBoton();
    }
Beispiel #2
0
    protected void B_Recuperar_Click(object sender, EventArgs e)
    {
        GenerarToken tok = new GenerarToken(Session["idioma"].ToString());

        try
        {
            tok.correoGenerar(TB_User_Name.Text);
#pragma warning disable CS0618 // Type or member is obsolete
            RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('" + tok.Get_mensaje() + "');</script>");
#pragma warning restore CS0618 // Type or member is obsolete
        }
        catch (Exception wejee)
        {
#pragma warning disable CS0618 // Type or member is obsolete
            RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('" + wejee.Message + "');</script>");
#pragma warning restore CS0618 // Type or member is obsolete
        }
    }
Beispiel #3
0
    public string GenerateJwtToken(GenerarToken modelo)
    {
        var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("d9db4fc5-4ddd-4309-97e3-4d0e74fe01f9"));

        // Creamos los claims (pertenencias, características) del usuario
        var claims = new[]
        {
            new Claim(ClaimTypes.Name, modelo.Cuenta),
            new Claim(ClaimTypes.Email, modelo.Correo)
        };

        var tokenDescriptor = new SecurityTokenDescriptor
        {
            Subject            = new ClaimsIdentity(claims),
            Audience           = "Autorizacion:debe75a4-9780-42de-8438-8c4c8cdd61a1",
            Issuer             = "https://api-epm-dev-autorizacion.azurewebsites.net/",
            Expires            = DateTime.UtcNow.AddHours(1),
            SigningCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature)
        };
        var tokenHandler = new JwtSecurityTokenHandler();
        var createdToken = tokenHandler.CreateToken(tokenDescriptor);

        return(this._jwtSecurityTokenHandler.WriteToken(createdToken));
    }