name: auth description: Internlink authentication reference. Use when changing signup, login, logout, session hydration, realm routing, or authentication validation/security behavior.
Auth Skill Reference
Auth agents cover Register, Login, and Logout. Routes are global (no school prefix) but the flows seed the realm session keys that other controllers expect.
Access Rights
- Register (
/signup): Students and supervisors only. Existing accounts should use Settings → Security for password changes. - Login (
/login): All roles. Developers land on the global dashboard, others are redirected into their school realm. - Logout (
/logout): Any authenticated user via POST.
Register — /signup
- Step 1 (user + school): Full Name, Email, Password (min 8), Phone, School Code, Role (
studentorsupervisor).- School code match is case-insensitive against
app.schools.code. - Email must be unique within the matched school.
- School code match is case-insensitive against
- Step 2 (role-specific profile):
- Student: Student Number, National Student Number, Major (free text), Batch (year), optional Photo URL.
- Supervisor: Supervisor Number, Department (text), Photo URL (required).
- Data is stored in
core.usersplus the role profile table (app.students/app.supervisors) inside a transaction-like sequence. Password hashes automatically via thehashedcast on the User model. - On success the session receives
user_id,role,school_id, andschool_code, and the user is redirected to/(which routes into the realm dashboard for non-developers). - Users can navigate back to Step 1; the form preserves entered data via session caches.
Login — /login
- Inputs: Email, Password.
- Developer accounts skip the school lookup; other roles must have a school associated or the form returns “Account not linked to a school”.
- Successful login writes the same session keys as registration and regenerates the session id.
Logout — /logout
- POST route with CSRF token.
- Calls
Auth::logout(), invalidates the session, regenerates the token, and redirects to/loginwith a flash message.
Session & Realm Notes
- Middleware
auth.sessionprotects post-login routes and expectsuser_id,role, and realm information in the session. - If a non-developer reaches
/withoutschool_code, the root route resolves it fromschool_idand stores it instantly. - Developers can enter any realm via
/schools→ Realm button; the code is stored in session for the duration of that visit.
Validation & Security
- Phone inputs are validated as
numericduring registration but stored as strings; reuse the same trimming when editing profiles. - Supervisor numbers use a regex guard (
^[A-Za-z0-9_-]+$, max 64 chars). - Student batch must pass
date_format:Y. - Read
references/security.mdbefore altering these flows: CSRF tokens, password hashing, and session regeneration are mandatory.