Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How can I automatically sign-in a user after they set their password in a Blazor interactive SSR page?

$
0
0

We have a Blazor (8) Interactive Server site. It is using cookies auth and was built using the standard blazor templates. I have an interactive Set Password page, which successfully creates the user (from a button click in a form); that user can then be used to log in from the static login page. We would like to be able to log the user in automatically as soon as the user is created, which is a problem in an interactive page because we don't have access to the HttpContext that the SignInManager uses, and the form doesn't POST in the usual way because it's using a SignalR connection to interactively create the user. How can I get around this? I can see the following options:

  • Make the Set Password page static (not a great option, as we will have to write a load of javascript to reproduce its existing functionality)
  • Add some javascript to the existing page in order to create the user and log them in via a REST API controller action method (again, not great because we need to bind that action to a DOM element that does not exist when the page loads - the docs advise against doing this)
  • Create a blazor WASM page for the Set Password page and log in via a REST API endpoint (quite a lot of work)
  • Somehow get the interactive page to automatically POST to a login url once the user is created (not sure this is possible)

Are there any better options? We somehow need to break out of the SignalR flow to perform an HTTP POST as soon as the interactive processing is complete.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>