Customer
Within Buddi there is a customer object. You can use this object if you want to find out if the customer is logged in or get the customer details.
Example:
{
data: undefined, //includes the customer details when logged in
guest_id: 6522871166632, //guest_id - you don't need it
is_logged_in: false //shows if the customer is logged in
token: undefined //the customer's auth token - you don't need it
}
The data property contains the currently logged in customer details(if logged in).
Customer auth notes
The Buddi customer can be in 2 states in your application: logged in or guest. In both cases you can add products to cart, place orders, pull products without any restrictions.
Once the Buddi.loginCustomer method is called - all subsequent requests will be attached to this logged in customer (if the login was successful).
When you login the customer the main module automatically caches the customer’s token for 12 hours. For example when the customer refreshes the page, you don’t need to force him to login again. Just check Buddi.customer.is_logged_in prop to find out if he is logged in.
If the customer is logged in and you call Buddi.logoutCustomer - all subsequent requests will be sent for the ‘guest’.