@@ -53,6 +53,23 @@ define(function (require, exports, module) {
5353 return LoginService . isLoggedIn ( ) ;
5454 }
5555
56+ /**
57+ * Attempts to sign in to the user's account if the user is not already logged in.
58+ * You should listen to `EVENT_ENTITLEMENTS_CHANGED` to know when the login status changes. This function
59+ * returns immediately and does not wait for the login process to complete.
60+ *
61+ * @return {void } Does not return a value.
62+ */
63+ function loginToAccount ( ) {
64+ if ( isLoggedIn ( ) ) {
65+ return ;
66+ }
67+ KernalModeTrust . loginService . signInToAccount ( )
68+ . catch ( function ( err ) {
69+ console . error ( "Error signing in to account" , err ) ;
70+ } ) ;
71+ }
72+
5673 /**
5774 * Get the plan details from entitlements with fallback to free plan defaults. If the user is
5875 * in pro trial(isInProTrial API), then paidSubscriber will always be true as we need to treat user as paid.
@@ -164,7 +181,8 @@ define(function (require, exports, module) {
164181 isInProTrial,
165182 getTrialRemainingDays,
166183 getRawEntitlements,
167- getLiveEditEntitlement
184+ getLiveEditEntitlement,
185+ loginToAccount
168186 } ;
169187 }
170188
@@ -173,6 +191,7 @@ define(function (require, exports, module) {
173191
174192 // Add functions to secure exports
175193 Entitlements . isLoggedIn = isLoggedIn ;
194+ Entitlements . loginToAccount = loginToAccount ;
176195 Entitlements . getPlanDetails = getPlanDetails ;
177196 Entitlements . isInProTrial = isInProTrial ;
178197 Entitlements . getTrialRemainingDays = getTrialRemainingDays ;
0 commit comments