fix: `props` is initialized but never used (#26659)

* fix: `props` is initialized but never used

The `props` variable which holds the authentication tokens from the external provider, is initialized in line 247 but never actually used. Changed line 269 to use it.

* docfix: `props` initialized but never used

The `props` variable is initialized but never used, the sample code was updated in a previous commit (f8528ea2e5) and this change in the documentation reflects that change by highlighting the line.

* Change `isPersistent` to `false` to conform to previous call to `SignInAsync`
pull/26674/head
Aviad Pineles 2022-08-09 21:15:32 +03:00 committed by GitHub
parent 38988db393
commit de7469aaef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -88,7 +88,7 @@ When `OnPostConfirmationAsync` executes, store the access token ([ExternalLoginI
The sample app saves the access token in `OnPostConfirmationAsync` (new user registration) and `OnGetCallbackAsync` (previously registered user) in `Account/ExternalLogin.cshtml.cs`:
[!code-csharp[](additional-claims/samples/6.x/ClaimsSample/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs?name=snippet_OnPostConfirmationAsync&highlight=49-53)]
[!code-csharp[](additional-claims/samples/6.x/ClaimsSample/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs?name=snippet_OnPostConfirmationAsync&highlight=49-53,73)]
> [!NOTE]
> For information on passing tokens to the Razor components of a Blazor Server app, see <xref:blazor/security/server/additional-scenarios#pass-tokens-to-a-blazor-server-app>.

View File

@ -246,7 +246,7 @@ namespace WebGoogOauth.Areas.Identity.Pages.Account
// using Microsoft.AspNetCore.Authentication;
var props = new AuthenticationProperties();
props.StoreTokens(info.AuthenticationTokens);
props.IsPersistent = true;
props.IsPersistent = false;
var userId = await _userManager.GetUserIdAsync(user);
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
@ -266,7 +266,7 @@ namespace WebGoogOauth.Areas.Identity.Pages.Account
return RedirectToPage("./RegisterConfirmation", new { Email = Input.Email });
}
await _signInManager.SignInAsync(user, isPersistent: false, info.LoginProvider);
await _signInManager.SignInAsync(user, props, info.LoginProvider);
return LocalRedirect(returnUrl);
}
}