main
|
Last change
on this file since 8b447ef was b715712, checked in by Stefan <trsunovstefan@…>, 8 weeks ago |
|
Add the server side and configuration
|
-
Property mode
set to
100644
|
|
File size:
981 bytes
|
| Line | |
|---|
| 1 | # Use-case 0002 Implementation — Log in
|
|---|
| 2 |
|
|---|
| 3 | **Initiating actor:** Visitor. **Source file:** `server/auth.go`, function `Login` + `authenticate`.
|
|---|
| 4 |
|
|---|
| 5 | ## Scenario (implemented)
|
|---|
| 6 |
|
|---|
| 7 | 1. **User** chooses option `[2] Login`.
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | 2. **System** prompts for username and password.
|
|---|
| 11 |
|
|---|
| 12 | 3. **User** enters `alice` / `test123`.
|
|---|
| 13 |
|
|---|
| 14 | 4. **System** looks up the user and compares hashes:
|
|---|
| 15 |
|
|---|
| 16 | ```sql
|
|---|
| 17 | SELECT id, password_hash FROM users WHERE username = $1;
|
|---|
| 18 | ```
|
|---|
| 19 |
|
|---|
| 20 | The Go side (`authenticate` in `server/auth.go`) compares the returned `password_hash` against `sha256hex(entered_password)`.
|
|---|
| 21 |
|
|---|
| 22 | 5. **System** on success stores `{UserID, Username}` in the in-process `Session` and shows the authenticated menu.
|
|---|
| 23 |
|
|---|
| 24 | 
|
|---|
| 25 |
|
|---|
| 26 | ## Seed credentials
|
|---|
| 27 |
|
|---|
| 28 | | Username | Password | Balance |
|
|---|
| 29 | |----------|----------|---------|
|
|---|
| 30 | | `alice` | `test123` | 10000.00 USD |
|
|---|
| 31 | | `bob` | `test123` | 5000.00 USD |
|
|---|
| 32 | | `charlie` | `test123` | 2500.00 USD |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.