In the application, users are registered through Microsoft Identity. Now from admin side i can deactivate the user and activate the user as well.
But on deactivation i want to logout the user from all the devices he is logged in but this is not working.
`[HttpPost(“UpdateBuyerApplicationStatus”)]
public async Task UpdateBuyerApplicationStatus([FromBody] StatusUpdateRequest request)
{
var response = _buyerApplicationBusinessLogic.UpdateBuyerApplicationStatus(request.Id);
var systemUser = await _userManager.FindByIdAsync(response.Data.ToString());
string reason = “”;
if (systemUser.Status == Framework.Enums.AccountStatus.Active)
{
systemUser.Status = Framework.Enums.AccountStatus.Deactivated;
reason = request.Reason;
}
else if (systemUser.Status == Framework.Enums.AccountStatus.Deactivated)
{
systemUser.Status = Framework.Enums.AccountStatus.Active;
}
await _userManager.UpdateAsync(systemUser);
**if (systemUser.Status == Framework.Enums.AccountStatus.Deactivated)
{
await _signInManager.SignOutAsync();
}**
string subject = "Application Status Update";
string templatePath = Path.Combine(Directory.GetCurrentDirectory(), "templates", "buyerStatus_email_template.html");
string bodyTemplate = await System.IO.File.ReadAllTextAsync(templatePath);
string reasonBlock = string.IsNullOrEmpty(reason) ? "" :
$"<p>Your account has been deactivated for the following reason: {reason}.</p>" +
$"<p>If you believe this is a mistake, you can contact us through this email or our support desk." +
$" Please visit the following URL for our support desk: <a href='https://edmnetwork.atlassian.net/servicedesk/customer/portal/4/group/21'>Support Desk</a></p>";
string body = bodyTemplate
.Replace("{{Name}}", (systemUser.FirstName + " " + systemUser.LastName))
.Replace("{{Status}}", systemUser.Status.ToString())
.Replace("{{ReasonBlock}}", reasonBlock)
.Replace("{{Year}}", DateTime.Now.Year.ToString());
_mailManager.SendEmail((systemUser.FirstName + " " + systemUser.LastName), systemUser.Email, subject, body);
return Ok(response);
}`