-- Compare admin@demo.com vs admin@powdercoating.com to find differences
-- Run this against PowderCoatingDb

-- Check both users side by side
SELECT
    'admin@demo.com' as UserAccount,
    Id,
    UserName,
    Email,
    EmailConfirmed,
    PhoneNumber,
    PhoneNumberConfirmed,
    TwoFactorEnabled,
    LockoutEnd,
    LockoutEnabled,
    AccessFailedCount,
    CompanyId,
    CompanyRole,
    FirstName,
    LastName,
    LEN(SecurityStamp) as SecurityStampLength,
    LEN(ConcurrencyStamp) as ConcurrencyStampLength,
    LEN(PasswordHash) as PasswordHashLength,
    LEN(NormalizedUserName) as NormalizedUserNameLength,
    LEN(NormalizedEmail) as NormalizedEmailLength
FROM AspNetUsers
WHERE Email = 'admin@demo.com'

UNION ALL

SELECT
    'admin@powdercoating.com' as UserAccount,
    Id,
    UserName,
    Email,
    EmailConfirmed,
    PhoneNumber,
    PhoneNumberConfirmed,
    TwoFactorEnabled,
    LockoutEnd,
    LockoutEnabled,
    AccessFailedCount,
    CompanyId,
    CompanyRole,
    FirstName,
    LastName,
    LEN(SecurityStamp) as SecurityStampLength,
    LEN(ConcurrencyStamp) as ConcurrencyStampLength,
    LEN(PasswordHash) as PasswordHashLength,
    LEN(NormalizedUserName) as NormalizedUserNameLength,
    LEN(NormalizedEmail) as NormalizedEmailLength
FROM AspNetUsers
WHERE Email = 'admin@powdercoating.com';

-- Check for any user claims
SELECT
    u.Email,
    uc.ClaimType,
    uc.ClaimValue,
    LEN(uc.ClaimValue) as ClaimValueLength
FROM AspNetUserClaims uc
INNER JOIN AspNetUsers u ON u.Id = uc.UserId
WHERE u.Email IN ('admin@demo.com', 'admin@powdercoating.com')
ORDER BY u.Email;

-- Check user roles
SELECT
    u.Email,
    r.Name as RoleName
FROM AspNetUsers u
INNER JOIN AspNetUserRoles ur ON u.Id = ur.UserId
INNER JOIN AspNetRoles r ON ur.RoleId = r.Id
WHERE u.Email IN ('admin@demo.com', 'admin@powdercoating.com')
ORDER BY u.Email;
