| | 1 | = Use-case 0001 Implementation - Login |
| | 2 | |
| | 3 | '''Initiating actor:''' Guest |
| | 4 | |
| | 5 | '''Other actors:''' None |
| | 6 | |
| | 7 | '''Description:''' |
| | 8 | 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. |
| | 9 | |
| | 10 | '''Scenario:''' |
| | 11 | 1. Guest goes to the login page. |
| | 12 | |
| | 13 | [[Image(UC0001LogIn_1.png)]] |
| | 14 | |
| | 15 | 2. Guest enters their username and password credentials. |
| | 16 | 3. Guest submits the form. |
| | 17 | 3. System checks the database to verify if the credentials exist and if they are correct: |
| | 18 | {{{ |
| | 19 | #!sql |
| | 20 | Hibernate: |
| | 21 | select |
| | 22 | u1_0.user_id, |
| | 23 | case |
| | 24 | when u1_1.user_id is not null |
| | 25 | then 1 |
| | 26 | when u1_2.user_id is not null |
| | 27 | then 2 |
| | 28 | when u1_0.user_id is not null |
| | 29 | then 0 |
| | 30 | end, |
| | 31 | u1_0.email, |
| | 32 | u1_0.first_name, |
| | 33 | u1_0.last_name, |
| | 34 | u1_0.password, |
| | 35 | u1_0.username, |
| | 36 | u1_2.user_id |
| | 37 | from |
| | 38 | project.users u1_0 |
| | 39 | left join |
| | 40 | project.pet_owners u1_1 |
| | 41 | on u1_0.user_id=u1_1.user_id |
| | 42 | left join |
| | 43 | project.pet_sitters u1_2 |
| | 44 | on u1_0.user_id=u1_2.user_id |
| | 45 | where |
| | 46 | u1_0.username=? |
| | 47 | |
| | 48 | }}} |
| | 49 | 4. The user logs in, the system determines their role (Owner, Sitter, or Admin), and redirects them to their dashboard. |
| | 50 | |
| | 51 | [[Image(UC0001LogIn_2.png)]] |