Skip to content

Commit

Permalink
return to password login screen when we cancel out of passkey logins
Browse files Browse the repository at this point in the history
  • Loading branch information
ghstahl committed May 19, 2024
1 parent 5d1de36 commit 1bfc553
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env.ngrok
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DOMAIN=51ed-47-150-126-75.ngrok-free.app
DOMAIN=ad79-47-150-126-75.ngrok-free.app
3 changes: 2 additions & 1 deletion cmd/server/static/js/webauthn.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function registerUser(returnUrl) {
}
}

async function LoginUser() {
async function LoginUser(returnFailedUrl) {
try {
const response = await fetch("/webauthn/login/begin");
if (!response.ok) {
Expand Down Expand Up @@ -131,5 +131,6 @@ async function LoginUser() {
} catch (error) {
console.error("Error:", error);
alert("Login failed!"); // More specific message based on error
window.location.href = returnFailedUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<script>
window.onload = function() {
LoginUser();
LoginUser({{ .returnFailedUrl }});
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ func (s *service) DoPost(c echo.Context) error {

log.Debug().Msg("OIDCLoginPasskey")

return s.Render(c, http.StatusOK, "oidc/oidcloginpasskey/index", map[string]interface{}{})
return s.Render(c, http.StatusOK,
"oidc/oidcloginpasskey/index",
map[string]interface{}{
"returnFailedUrl": wellknown_echo.OIDCLoginPasswordPath,
})
}

func (s *service) Do(c echo.Context) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func AddScopedIHandler(builder di.ContainerBuilder) {
stemService.Ctor,
[]contracts_handler.HTTPVERB{
// Using only auto post here so that our arguments are present in the URL
// contracts_handler.GET,
contracts_handler.GET,
contracts_handler.POST,
},
wellknown_echo.OIDCLoginPasswordPath,
Expand Down

0 comments on commit 1bfc553

Please sign in to comment.