The Employee module provides access to information about the currently authenticated employee within the server-side execution context. It includes methods for checking authentication status, retrieving employee identity, and evaluating role-based permissions.
This module is essential for implementing secure logic based on the identity and privileges of the employee making the request - such as controlling access to admin-only features or conditionally executing code based on assigned roles or permissions.
Note: The Employee module is globally available in the SDK environment via kd.employee.
The kd.employee module is available in any server-side context or middleware, making it easy to integrate secure employee-specific logic throughout your Kodaris platform.
Checks whether an employee user is currently logged in with an active session.
if (kd.employee.isLoggedIn()) {
// Perform employee-only operations
} else {
// Handle unauthorized access
}
Retrieves the employee object for the currently logged-in employee.
// Get the current employee's information
var employee = kd.employee.get();
/* Sample Response:
{
administratorID: 123456,
firstName: "Jane",
userName: "jane.smith@kodaris.com"
}
*/
Checks if the currently logged-in employee has a specific role.
// Check if the current employee has the ADMIN role
var isSuperuser = kd.employee.hasRole("superuser");
/* Sample Response:
true // Employee has the superuser role
*/
// Using role verification for conditional operations
if (kd.employee.hasRole("contentEdit")) {
// Allow content management operations
} else {
// Show unauthorized message or hide content management features
}