Wix Get Current User

import wixUsers from 'wix-users';

 

// ...

 

let user = wixUsers.currentUser;

 

let userId = user.id; // "r5cme-6fem-485j-djre-4844c49"

let isLoggedIn = user.loggedIn; // true

 

user.getEmail()

.then( (email) => {

let userEmail = email; // "user@something.com"

} );

 

user.getRoles()

.then( (roles) => {

let firstRole = roles[0];

let roleName = firstRole.name; // "Role Name"

let roleDescription = firstRole.description; // "Role Description"

} );

 

user.getPricingPlans()

.then( (pricingPlans) => {

let firstPlan = pricingPlans[0];

let planName = firstPlan.name; // "Gold"

let startDate = firstPlan.startDate; // Wed Aug 29 2018 09:39:41 GMT-0500 (Eastern Standard Time)

let expiryDate = firstPlan.expiryDate; // Thu Nov 29 2018 08:39:41 GMT-0400 (Eastern Daylight Time)

} );

import wixUsers from 'wix-users';

 

// ...

 

wixUsers.applySessionToken(sessionToken)

.then( () => {

console.log("User logged in.");

} );