= Use-case 0001 Implementation - Login '''Initiating actor:''' Guest '''Other actors:''' None '''Description:''' A guest wants to access their personalized profile in the system. If the guest attempts to perform a restricted action, they must log in. The guest logs in by providing a username and password. The system verifies the credentials and if valid, starts an authenticated session. '''Scenario:''' 1. Guest goes to the login page. [[Image(UC0001LogIn_1.png)]] 2. Guest enters their username and password credentials. 3. Guest submits the form. 3. System checks the database to verify if the credentials exist and if they are correct: {{{ #!sql Hibernate: select u1_0.user_id, case when u1_1.user_id is not null then 1 when u1_2.user_id is not null then 2 when u1_0.user_id is not null then 0 end, u1_0.email, u1_0.first_name, u1_0.last_name, u1_0.password, u1_0.username, u1_2.user_id from project.users u1_0 left join project.pet_owners u1_1 on u1_0.user_id=u1_1.user_id left join project.pet_sitters u1_2 on u1_0.user_id=u1_2.user_id where u1_0.username=? }}} 4. The user logs in, the system determines their role (Owner, Sitter, or Admin), and redirects them to their dashboard. [[Image(UC0001LogIn_2.png)]]