zh Kooboo Logo Documents

Account

 

The Account namespace is used for user authentication and login functionality
 
 
code for user login
 
let loginUser = k.account.login("username", "password");  
 
To ensure that only authenticated users can access certain parts of your application and redirect non-authenticated users
 
k.account.ensureLogin("/redirecttologin"); 
 
To get user information
 
let user= k.account.user.current; 
let org = k.account.organization.current; 
let usrDeparts = k.account.user.current.departments
let orgDeparts = k.account.organization.current.departments
 
OAUTH
 
To implement third-party login, such as Facebook login, you need to configure the App ID, Secret, and callback method in the system settings.
 
Here's an example of how you can implement Facebook login:
 
<div>
   <script env=server> 
       var url = k.oAuth2.facebook.getAuthUrl() 
   </script>
   <a k-href='url'>facebook login</a> 
</div>