| | 1 | = UC0009 Prototype Implementation - Register a New User = |
| | 2 | |
| | 3 | '''Initiating actor:''' Faculty Administrator |
| | 4 | |
| | 5 | '''Other actors:''' None |
| | 6 | |
| | 7 | The administrator creates a new user account by entering personal details, selecting a role from the available user types, and setting an initial password. The system validates email uniqueness, hashes the password with bcrypt, and inserts the new user. |
| | 8 | |
| | 9 | == Scenario == |
| | 10 | |
| | 11 | 1. The administrator selects ''Register a New User'' from the main menu. The system queries available roles: |
| | 12 | {{{ |
| | 13 | SELECT type_id, type_name, description FROM user_types ORDER BY type_id; |
| | 14 | }}} |
| | 15 | |
| | 16 | The system displays the role selection menu: |
| | 17 | {{{ |
| | 18 | === Register a New User === |
| | 19 | |
| | 20 | Available roles: |
| | 21 | 1. Student - Students can view resource availability and access permitted resources |
| | 22 | 2. Teaching Staff - Faculty members who can reserve resources for lectures, labs, and research |
| | 23 | 3. Administrator - System administrators who manage resources and approve reservations |
| | 24 | 0. Cancel / Go back |
| | 25 | }}} |
| | 26 | |
| | 27 | 2. The administrator selects ''Teaching Staff'' and enters the new user's details. |
| | 28 | {{{ |
| | 29 | Select role: 2 |
| | 30 | First name: Petar |
| | 31 | Last name: Jovanov |
| | 32 | Email: petar.jovanov@finki.ukim.mk |
| | 33 | }}} |
| | 34 | |
| | 35 | 3. The system checks that the email is not already registered. |
| | 36 | {{{ |
| | 37 | SELECT COUNT(*) FROM users WHERE email = 'petar.jovanov@finki.ukim.mk'; |
| | 38 | }}} |
| | 39 | |
| | 40 | 4. The email is available. The administrator sets the initial password. |
| | 41 | {{{ |
| | 42 | Initial password: ******** |
| | 43 | Confirm password: ******** |
| | 44 | }}} |
| | 45 | |
| | 46 | 5. The system hashes the password with bcrypt and inserts the new user account: |
| | 47 | {{{ |
| | 48 | INSERT INTO users (first_name, last_name, email, password, type_id) |
| | 49 | VALUES ('Petar', 'Jovanov', 'petar.jovanov@finki.ukim.mk', '$2b$12$...hashed...', 2) |
| | 50 | RETURNING user_id, first_name, last_name, email; |
| | 51 | }}} |
| | 52 | |
| | 53 | The system confirms the account was created: |
| | 54 | {{{ |
| | 55 | User created successfully! |
| | 56 | User ID: 13 |
| | 57 | Name: Petar Jovanov |
| | 58 | Email: petar.jovanov@finki.ukim.mk |
| | 59 | Role: Teaching Staff |
| | 60 | }}} |
| | 61 | |
| | 62 | == Alternative: Email Already Exists == |
| | 63 | |
| | 64 | 3a. If the email is already registered, the system displays an error. |
| | 65 | {{{ |
| | 66 | ERROR: A user with email 'elena.stojanova@finki.ukim.mk' already exists. |
| | 67 | }}} |