Skip to content

Commit

Permalink
PAS290: Demo example is returning the wrong status code in the respon…
Browse files Browse the repository at this point in the history
…se (#97)
  • Loading branch information
jonashendrickx authored Dec 15, 2023
1 parent a9d28bc commit e22baea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions examples/Passwordless.Example/PasswordlessController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

Expand Down Expand Up @@ -45,7 +46,7 @@ public async Task<IActionResult> GetRegisterToken(string alias)
{
return new JsonResult(e.Details)
{
StatusCode = (int?)e.StatusCode
StatusCode = e.Details.Status
};
}
}
Expand All @@ -71,7 +72,7 @@ public async Task<IActionResult> VerifySignInToken(string token)
{
return new JsonResult(e.Details)
{
StatusCode = (int?)e.StatusCode
StatusCode = e.Details.Status
};
}
}
Expand Down
10 changes: 9 additions & 1 deletion examples/Passwordless.Example/wwwroot/client-signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@ async function handleSigninClick(e) {
}

console.log("Received token", token);

/**
* Verify the sign in - Call your node backend to verify the token created from the sign in
*/
const user = await fetch(BACKEND_URL + "/verify-signin?token=" + token).then((r) => r.json());
const userResponse = await fetch(BACKEND_URL + "/verify-signin?token=" + token);
if (!userResponse.ok) {
const userError = await userResponse.json();
Status("Your backend failed while verifying the token: " + JSON.stringify(userError, null, 2));
return;
}

const user = await userResponse.json()

/**
* Done - you can now check the user result for status, userid etc
Expand Down
4 changes: 2 additions & 2 deletions src/Passwordless/PasswordlessApiException.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Passwordless;

public sealed class PasswordlessApiException : HttpRequestException
public sealed class PasswordlessApiException : Exception
{
public PasswordlessProblemDetails Details { get; }

Expand Down

0 comments on commit e22baea

Please sign in to comment.