ROCKVIEW STUDENT STUDIOS - INDEPENDENT USERS API
================================================

This backend is independent of the university's other databases. It uses only
intranetrockview_slps_studio and the studio_* / hr_* tables created by the
standalone schema.

DEPLOYMENT
----------
1. Create/select PostgreSQL database: intranetrockview_slps_studio.
2. Import database/student_studios_schema.sql.
3. Upload the contents of api/ into:
       public_html/students/api/
4. Copy config/database.php.example to config/database.php and enter the
   PostgreSQL host, database name, role and password. Keep database.php private.
5. Ensure PHP has pdo_pgsql enabled and HTTPS is active.
6. Create the first administrator from a shell/SSH session after the API and
   config are in place:

   export STUDIO_ADMIN_NAME='Studio Administrator'
   export STUDIO_ADMIN_EMAIL='admin@example.com'
   export STUDIO_ADMIN_USERNAME='studioadmin'
   export STUDIO_ADMIN_PASSWORD='Use-A-Long-Random-Password-Here'
   php setup/create_first_admin.php

   If shell access is unavailable, ask the hosting administrator to run this
   CLI script. Do not expose it as a public web endpoint.
7. Apply the Flutter overlay files to the matching paths in your lib folder.
   The Studio Users screen will prompt for a separate Studio username/password.

ENDPOINTS
---------
POST /students/api/studio_auth.php?action=login
GET  /students/api/studio_auth.php?action=me
POST /students/api/studio_auth.php?action=logout
GET  /students/api/studio_users.php?action=bootstrap
POST /students/api/studio_users.php?action=save
POST /students/api/studio_users.php?action=status
POST /students/api/studio_users.php?action=reset_password
POST /students/api/studio_users.php?action=delete

Authenticated requests use X-Studio-Session. Tokens are random 256-bit values;
only SHA-256 token hashes are stored in studio_user_sessions. Passwords use
PHP password_hash/password_verify. Sessions expire after 12 hours. Suspended,
disabled or deleted users cannot authenticate. Password resets revoke sessions.

SECURITY NOTES
--------------
- The first Studio Super Administrator is created through a CLI-only script.
- Only the studio_super_admin role can administer Studio users.
- Never put database credentials in Flutter source code.
- Keep config/database.php outside public access if your hosting layout allows.
- Use HTTPS; configure web server rules to deny direct access to config/ and
  setup/ directories. The setup script itself refuses non-CLI execution.
- The Flutter overlay still sits inside the existing admin dashboard shell;
  the Studio Users screen itself now requires a separate Studio login.

IMPORTANT COMPATIBILITY
-----------------------
This API package implements the Studio Users and Studio authentication
endpoints. The News Studio and Forms Studio APIs must also be updated to use
studio_auth.php / studio_user_sessions if those modules are to be fully
independent. This package does not claim those other APIs have been converted.
