0

I need to give different session length to users according to a certain role. Since session length is configured in program.cs I tried to check the role in it. The problem that in order to us IsInRole(...) function I need to know who is the current user which I don't. Is it possible to do it like that? Any other way to do it?

tzviya
  • 537
  • 1
  • 4
  • 14
  • Please show your attempts you have tried and the problem/error messages you get from your attempts. – Qing Guo Jun 21 '23 at 01:45
  • That what chat GPT suggested: // Retrieve the current user by their unique identifier (e.g., email) var adminUser = userManager.FindByEmailAsync("admin@example.com").Result; // Check if the admin user exists and belongs to the "admin" role if (adminUser != null && userManager.IsInRoleAsync(adminUser, "admin").Result) { // The current user is an admin, perform necessary actions // You can set a flag or store this information for later use } but he wants me to provide the unique identifier... – tzviya Jun 21 '23 at 07:19
  • It is not possible to configure session timeouts by role or user. You can only set it for the application. – Mike Brind Jun 21 '23 at 08:39

0 Answers0