User status in SCA shopping

187 Views Asked by At

Is there a simple way to check the user's logged in/out status in ALL areas of the SCA front-end? ie:

{{if isLoggedIn}}
    do this
{{else}}
    do that
{{/if}}
1

There are 1 best solutions below

1
On

depending on the version of SCA you are using you can use the global variable SC.

either

SC.PROFILE.isLoggedIn

or

SC.PROFILE_PROMISE.then(function(profile){
    console.log(profile.isLoggedIn);
});

You can also include the user profile in any of your models:

define(
    'MyModule'
,   [   'Profile.Model'

    ]
,   function (

        ProfileModel
    )
{
    'use strict';


    return {

        mountToApp: function(application){
           var profile_model = ProfileModel.getInstance();
            if (profile_model.get('isLoggedIn') === 'F')