Trying to ID Users

Hi all. I need to be able to classify users as Logged-In Members, Non-Members (with unlogged in members too) and Admins. This is the code I am struggling with…I can’t get it to pick up the noin-members - its detecting logged-in users and Admins fine…but not the third category for payType.

async function defineUser() {
let user = wixUsers.currentUser;
let userId = user.id;           // "r5cme-6fem-485j-djre-4844c49"
let isLoggedIn = user.loggedIn; // true

let email = await user.getEmail();
let userEmail = email;      // "user@something.com"
console.log("userEmail: "+userEmail);
memory.setItem("userEmail", userEmail);

if (isLoggedIn){
  try{
    const roles = await user.getRoles();
    let firstRole = roles[0];
    let payType = firstRole.name;    // "Role Name"
    console.log("payType: "+payType);
    return payType;
    }
    catch(error) {
    let payType = "Member";
    console.log("payType: "+payType);
    return payType;
    }
} else {
  let payType = "NonMember";
  console.log("payType: "+payType);
  return payType;
}
}

Any ideas how to come at this differently? Am I missing something dumb again? (That is usually my problem)

Thanks,
Simon.

If a user isn’t logged in yet, the getEmail throws an error.

Uncaught No user is currently logged in

Yep…that was it. Don’t remember see the error in teh console that clearly though. Thanks for the help.