Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
python fido2 server with if statement

I'm using the this example as inspiration for my project about Yubikey. At the end of authenticate.html, I want to add an if-statement. So if the authentication is successfull redirect to a specific page, and otherwise recirect back to the homepage. I've tried different places for the if-statement:

.then(function(response) {
  var stat = response.ok ? 'successful' : 'unsuccessful';
  alert('Authentication ' + stat + ' More details in server log...');
}, function(reason) {
  alert(reason);
}).then(
  function() {
    if(stat=='successful'){
      window.location.replace('https://google.com')
    }
    else {
      window.location = '/';
    }
});
}

and

.then(function(response) {
  var stat = response.ok ? 'successful' : 'unsuccessful';
  alert('Authentication ' + stat + ' More details in server log...');
  if(stat=='successful'){
      window.location.replace('https://google.com')
    }
    else {
      window.location = '/';
    }
}, function(reason) {
  alert(reason);
}).then(
  function() {
});
}

I've never seen Javascript before, but it seemed that I couldn't get around Yubikey and Python (I'm familiar with python) not using JS. None of the above has worked the intented ways.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Asuming you're using fetch then the correct (and simplest) way of handling this would be something like the following:

fetch('some-super-secret-endpoint')
.then(response => {
    if(response.ok)
        window.location = 'https://google.com'
    else 
        window.location = '/'
}).catch(e => {
    console.error(e)
})
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda