This commit is contained in:
Naden
2026-04-25 06:20:28 +07:00
parent 211f72fa3b
commit e908b7a1d6
3 changed files with 39 additions and 1 deletions

View File

@@ -22,4 +22,7 @@ $routes->group('api', function($routes) {
// Standard CRUD via DhivaRoutes (Keep for compatibility) // Standard CRUD via DhivaRoutes (Keep for compatibility)
DhivaRoutes::Route($routes, 'user', 'SuperUserController'); DhivaRoutes::Route($routes, 'user', 'SuperUserController');
}); });
// Catch all OPTIONS requests for CORS preflight
$routes->options('(:any)', function () {});

View File

@@ -22,6 +22,15 @@ class SuperUserController extends BaseController
$inputUsername = $this->post('username'); $inputUsername = $this->post('username');
$inputPassword = $this->post('password'); $inputPassword = $this->post('password');
// Fallback for JSON payload (Angular)
if (empty($inputUsername) || empty($inputPassword)) {
$json = $this->request->getJSON();
if ($json) {
$inputUsername = $json->username ?? null;
$inputPassword = $json->password ?? null;
}
}
if (empty($inputUsername) || empty($inputPassword)) { if (empty($inputUsername) || empty($inputPassword)) {
$this->respond([ $this->respond([
'success' => false, 'success' => false,

View File

@@ -25,6 +25,32 @@ CREATE TABLE IF NOT EXISTS kta_digital.personel (
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
); );
-- Table: public.super_user (Auth)
CREATE TABLE IF NOT EXISTS public.super_user (
super_user_id SERIAL PRIMARY KEY,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
name VARCHAR(255),
email VARCHAR(255),
avatar TEXT,
satuan_id INTEGER,
jabatan VARCHAR(255),
nrp VARCHAR(20),
pangkat VARCHAR(100),
no_wa VARCHAR(20),
super_group_id INTEGER,
login_date TIMESTAMP,
access_at TIMESTAMP,
token TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Seed demo admin user (username: dhivaadmin, password: dhivaadmin)
INSERT INTO public.super_user (username, password, name, super_group_id)
VALUES ('dhivaadmin', 'dhivaadmin', 'Admin KTA', 1)
ON CONFLICT DO NOTHING;
-- Table: kta_digital.pendidikan_kepolisian -- Table: kta_digital.pendidikan_kepolisian
CREATE TABLE IF NOT EXISTS kta_digital.pendidikan_kepolisian ( CREATE TABLE IF NOT EXISTS kta_digital.pendidikan_kepolisian (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,