wiki:UseCase0009PrototypeImplementation

Version 1 (modified by 221511, 5 days ago) ( diff )

--

UC0009 Prototype Implementation - Register a New User

Initiating actor: Faculty Administrator

Other actors: None

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.

Scenario

  1. The administrator selects Register a New User from the main menu. The system queries available roles:
    SELECT type_id, type_name, description FROM user_types ORDER BY type_id;
    

The system displays the role selection menu:

=== Register a New User ===

  Available roles:
  1. Student - Students can view resource availability and access permitted resources
  2. Teaching Staff - Faculty members who can reserve resources for lectures, labs, and research
  3. Administrator - System administrators who manage resources and approve reservations
  0. Cancel / Go back
  1. The administrator selects Teaching Staff and enters the new user's details.
      Select role: 2
      First name: Petar
      Last name: Jovanov
      Email: petar.jovanov@finki.ukim.mk
    
  1. The system checks that the email is not already registered.
    SELECT COUNT(*) FROM users WHERE email = 'petar.jovanov@finki.ukim.mk';
    
  1. The email is available. The administrator sets the initial password.
      Initial password: ********
      Confirm password: ********
    
  1. The system hashes the password with bcrypt and inserts the new user account:
    INSERT INTO users (first_name, last_name, email, password, type_id)
    VALUES ('Petar', 'Jovanov', 'petar.jovanov@finki.ukim.mk', '$2b$12$...hashed...', 2)
    RETURNING user_id, first_name, last_name, email;
    

The system confirms the account was created:

  User created successfully!
  User ID:  13
  Name:     Petar Jovanov
  Email:    petar.jovanov@finki.ukim.mk
  Role:     Teaching Staff

Alternative: Email Already Exists

3a. If the email is already registered, the system displays an error.

  ERROR: A user with email 'elena.stojanova@finki.ukim.mk' already exists.
Note: See TracWiki for help on using the wiki.