Overview
Faculty Bot implements a secure two-step email verification system that ensures only students with valid university email addresses can access the server. The system uses temporary verification codes sent via email and stores verified users in a PostgreSQL database.Verification Flow
Request Verification
Users initiate verification with
/verify init and provide their student email addressThe email must end with @stud.hs-kempten.de to be valid.Code Generation
A unique verification code is generated and temporarily stored in memoryThe code is sent to the provided email address via the email task system.
Submit Code
Users enter the code using
/verify code to complete verificationThe bot validates the code against the stored value.Implementation Details
Email Validation
The system validates email addresses at multiple stages:src/commands/user.rs:54-71
Code Storage
Verification codes are stored in a concurrent hashmap (DashMap) for temporary access:src/commands/user.rs:73-76
Database Insertion
Once the code is verified, the user is permanently added to the database:src/commands/user.rs:167-172
Role Assignment
After successful verification, users automatically receive the verified role:src/commands/user.rs:183-189
Commands
/verify init
Initiates the verification process by requesting a student email address.Parameters:
email- Student email ending in @stud.hs-kempten.de
/verify code
Completes verification by submitting the code received via email.Parameters:
code- Verification code from email
Re-verification System
For long-time members, administrators can trigger re-verification campaigns:src/commands/administration.rs:512-518
Users receive a DM with a “Reverify” button that opens a modal to re-submit their email address.
Security Features
Duplicate Prevention
Prevents multiple accounts from using the same email address
Temporary Codes
Verification codes are stored in memory and removed after use
Domain Restriction
Only emails from @stud.hs-kempten.de are accepted
Database Persistence
Verified users are permanently stored for future reference
Error Handling
The system provides localized error messages for common issues:- Invalid email format
- Email already in use
- Invalid verification code
- User already verified
src/commands/user.rs:48-52, 130-153