You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.2 KiB

  1. using CustomerPortalV2.Common.Model.AccountModel;
  2. using Microsoft.AspNetCore.Http;
  3. using System.Security.Claims;
  4. namespace CustomerPortalV2.Common.Helper
  5. {
  6. public static class LoginUserInfo
  7. {
  8. public static LoginResponse GetLoginDetails(this HttpContext context)
  9. {
  10. var claimIdentity = context.User.Identity as ClaimsIdentity;
  11. var model = new LoginResponse();
  12. if (claimIdentity.IsAuthenticated)
  13. {
  14. model.UserName = claimIdentity.FindFirst(x => x.Type == "UserName").Value;
  15. model.FullName = claimIdentity.FindFirst(x => x.Type == ClaimTypes.Name).Value;
  16. model.ForceChangePassword = Convert.ToBoolean(claimIdentity.FindFirst(x => x.Type == "ForceChangePassword").Value);
  17. model.MobileNumber = claimIdentity.FindFirst(x => x.Type == "MobileNumber").Value;
  18. model.Email = claimIdentity.FindFirst(x => x.Type == "Email").Value;
  19. model.RememberMe = Convert.ToBoolean(claimIdentity.FindFirst(x => x.Type == "RememberMe").Value);
  20. model.SessionId = claimIdentity.FindFirst(x => x.Type == "SessionId").Value;
  21. }
  22. return model;
  23. }
  24. }
  25. }