/// <summary> /// Gets the current authenticated used using JavaScript interop. /// </summary> /// <returns>A <see cref="Task{ClaimsPrincipal}"/>that will return the current authenticated user when completes.</returns> protected internal virtual async ValueTask <ClaimsPrincipal> GetAuthenticatedUser() { await EnsureAuthService(); var account = await JsRuntime.InvokeAsync <TAccount>("AuthenticationService.getUser"); var user = await AccountClaimsPrincipalFactory.CreateUserAsync(account, Options.UserOptions); return(user); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="jsRuntime">The <see cref="IJSRuntime"/> to use for performing JavaScript interop operations.</param> /// <param name="options">The options to be passed down to the underlying JavaScript library handling the authentication operations.</param> /// <param name="navigation">The <see cref="NavigationManager"/> used to generate URLs.</param> /// <param name="accountClaimsPrincipalFactory">The <see cref="AccountClaimsPrincipalFactory{TAccount}"/> used to generate the <see cref="ClaimsPrincipal"/> for the user.</param> public RemoteAuthenticationService( IJSRuntime jsRuntime, IOptionsSnapshot <RemoteAuthenticationOptions <TProviderOptions> > options, NavigationManager navigation, AccountClaimsPrincipalFactory <TAccount> accountClaimsPrincipalFactory) { JsRuntime = jsRuntime; Navigation = navigation; AccountClaimsPrincipalFactory = accountClaimsPrincipalFactory; Options = options.Value; }