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

How to authenticate a user based on the result of a function call in a Blazor server rending app in .NET 8

$
0
0

I've written my first Blazor app using the server-side rendering with SignalR.

I'm having trouble with authentication.

There is a function that performs a database query. If it returns true, the user is allowed to access the app. If it returns false, the user is to be directed to an org logon page.

I've read about some of the classes and components used to implement authentication, such as AuthorizationStateProvider and AuthorizedView, but I'm not clear on how I'm supposed to use them for this simple situation.

It's really very simple.

bool isAuthenticated = Helper.IsUserLoggedIn();if (!isAuthenticated){    // redirect user to logon page}

I know that I can invoke Helper.IsUserLoggedIn, I just want to know the usual best practice for setting this up properly with the framework; I might add additional functionality later.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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