I use this package:Microsoft.AspNetCore.Authentication.MicrosoftAccountSo, users can log on with their Microsoft (business) account.
I have a button enabled in my webapp that can remove an organization, by removing the organization you also agree that you're removing all included members.so, the method will go through all members and remove these (I know I can use RemoveRange in my example below).
The user initiating the button will also be deleted. after the method ran it returns to the home page, but when I click on the profile button I still see a user logged on, but as soon as I try to go the profile, it will redirect me to the log in page, which is good, but how can I make sure that when you click on the profile, you do not see someone "logged in"?
I tried to use SignInManager.SignOutAsync();, but that cannot work in interactive mode, but what else can I do then?
This is behind the 'Delete Organization' button:
public async Task OnValidSubmitAsync(){ //await SignInManager.SignOutAsync(); await CustomerService.DeleteCustomer(CancellationTokenSource.Token, Company);}and this is the DeleteCustomer method:
public async Task DeleteCustomer(CancellationToken cancellationToken, Customer customer) { try { using var Connector = await DbFactory.CreateDbContextAsync(cancellationToken); var customerToRemove = await Connector.Customers!.Include(n => n.UserPrincipalNameSuffixes).Include(n => n.Users).FirstOrDefaultAsync(n => n.Id == customer.Id, cancellationToken); if (customerToRemove != null) { if (customerToRemove.UserPrincipalNameSuffixes != null) { foreach (var domainSuffix in customerToRemove.UserPrincipalNameSuffixes) { Connector.DomainSuffixWithRole.Remove(domainSuffix); } } if (customerToRemove.Users != null) { foreach (var user in customerToRemove.Users) { var user1 = Connector.ApplicationUsers!.Include(n => n.ApplicationUserFavoriteGraphReport).Include(n => n.graphReportVotings).FirstOrDefault(n => n.Id == user.Id.ToString()); if (user1 != null) { if (user1.ApplicationUserFavoriteGraphReport != null) { foreach (var item in user1.ApplicationUserFavoriteGraphReport) { Connector.ApplicationUserFavoriteGraphReport!.Remove(item); } } if (user1.graphReportVotings != null) { foreach (var item in user1.graphReportVotings) { Connector.GraphReportVoting!.Remove(item); } } } Connector.ApplicationUsers!.Remove(user); } Connector.Customers!.Remove(customerToRemove); } await Connector.SaveChangesAsync(cancellationToken); //NavigationManager.NavigateTo("/Account/Logout", true); NavigationManager.NavigateTo($"/", true); } } catch (OperationCanceledException) { } }Please understand that this is a hobby and not my full time job, so I'm pretty sure lot's of coding mistakes can be found!
as you can see commented out, I also tried to redirect to the logout page / post.