Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
PasswordCredential does not store the data

I'm using the PasswordCredential API in Google Chrome and Edge to store authentication credentials, however this data is not saved.

I'm using the code below, and I only fire it if my AJAX login is successful.

var cred = new PasswordCredential({
    name: account,
    id: email,
    password: password,
    iconURL: 'https://example.com/favicon.ico'
});
navigator.credentials.store(cred).then(() => {
    if (redirect !== undefined) {
        $window.location.href = 'dashboard.html';
    }
});

If inside the then function of the .store I put it to pull the saved data, null data is displayed.

navigator.credentials.store(cred).then(() => {
    navigator.credentials.get({ password: true }).then(function (auth) {
        console.log(auth); //Return NULL
        console.log(auth.password); //Returns that does not exist
        console.log(auth.id); //Returns that does not exist
        console.log(auth.name); //Returns that does not exist
        
    });
});

What did I do wrong in my code?

Edit

I believe I found the problem, as the user chooses and not saving the credentials in the browser the promise is pending. Is there any way to do this automatically without the user having to manually save?

And how do I handle the promise when it completes?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As per W3C it store api will return the promise to make sure it has raised proper request to browser or not, it will not tell if use save or not. If you want to achieve this, you may create setInterval where you can regularly check by calling get from store.

Reference of W3C standard

In Reference to save, promise already shows fulfilled as below:

save credentials

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda