Skip to content

Commit

Permalink
Merge pull request #505 from jianyangg/503-update-dg-implementation-jy
Browse files Browse the repository at this point in the history
Update DG (JY)
  • Loading branch information
Gabriel4357 committed Nov 13, 2023
2 parents 5774324 + 6b557de commit 35a4088
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
50 changes: 27 additions & 23 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ This section describes some noteworthy details on how certain features are imple
- [Customer Edit Command](#customer-edit-command)
- [Delivery Add Command](#delivery-add-command)

<br>

### Update Delivery Status Feature

#### Overview
Expand Down Expand Up @@ -324,6 +322,7 @@ The sequence of the `delivery status` command is as follows:

The following sequence diagram illustrates the `delivery status` command sequence:


<puml src="diagrams/DeliveryStatusCommandSequenceDiagram.puml" width="900" />

<br>
Expand Down Expand Up @@ -381,7 +380,7 @@ The following diagram illustrates the `delivery note` command sequence:

<br>

### User Register Account Command
### <br/>User Register Account Command

**Overview:**
The `register` command is used to register a new user account.
Expand All @@ -391,42 +390,47 @@ The format for the `register` command can be found [here](UserGuide.md#register)

**Feature details:**

1. The user specifies the `Username`, `Password`, `Confirm Password`, `Forget Password Question`
and `Forget Password Answer` in the `register` command.
2. If any of the fields is not provided, an error message with the correct command usage will be shown.
3. If invalid command parameters are provided, an error message with the correct parameter format will be shown.
4. If the `Password` and `Confirm Password` fields do not match, an error message will be shown.
5. If the user is currently logged in, an error message will be shown.
6. The `User` is then cross-referenced with the stored user in `Model` to check if there's already a user stored. If
1. The user specifies the `USERNAME`{.swift}, `PASSWORD`{.swift}, `CONFIRM_PASSWORD`{.swift}, `SECRET_QUESTION`{.swift}
and `ANSWER`{.swift} in the `register`{.swift} command.
1. If any of the fields is not provided, an error message with the correct command format will be shown.
1. If command parameters provided are not within the acceptable value range, an error message with the correct command format will be shown.
1. If the `PASSWORD`{.swift} and `CONFIRM_PASSWORD`{.swift} fields do not match, an error message will be shown to
inform the user that the passwords do not match.
1. If the user is currently logged in, an error message will be shown.
1. The `User` is then cross-referenced with the stored user in `Model` to check if there's already a user stored. If
there's already a user stored, an error message will be shown.
7. If all the previous steps are completed without exceptions, the user will be registered and the `User` will be stored
1. If all the previous steps are completed without exceptions, the user will be registered and the `User` will be stored
in `Model`. The `isLoggedIn` status in `Model` will be updated to `true`.
1. The user's username, password, secret question and answer will then be stored in the `authentication.json` file. The password is hashed using SHA-256.

The following activity diagram shows the logic of a user registering an account:

<puml src="diagrams/UserRegisterActivityDiagram.puml" alt="UserRegisterActivityDiagram" />

The sequence of the `register` command is as follows:

1. The command `register INPUT` is entered by the user (e.g., register --user gab --password pass1234 --confirmPass
pass1234 --secretQn First Pet? --answer Koko).
2. Logic Manager calls the `AddressBookParser#parseCommand` with the `INPUT`.
3. The `AddressBookParser` parses the command word, creating an instance of `UserRegisterCommandParser` to parse the
1. The `register` command is entered by the user (i.e., `register --user gab --password pass1234 --confirmPass
pass1234 --secretQn First Pet? --answer Koko`).
1. Logic Manager calls the `AddressBookParser#parseCommand` with the full user input.
1. The `AddressBookParser` parses the command word, creating an instance of `UserRegisterCommandParser` to parse the
rest of the command.
4. If all fields are present, it checks if password and confirm password match.
5. If password and confirm password match, it creates an instance of `UserRegisterCommand`.
6. `Logic Manager` executes `UserRegisterCommand` by calling `UserRegisterCommand#execute()`.
7. `UserRegisterCommand` checks if a user is already registered by calling `Model#getStoredUser`.
8. If no user is registered, `UserRegisterCommand` calls `Model#registerUser` to store the user. Login status is set to
1. If not all fields are present, a `ParseException` is thrown saying incorrect command format.
1. If all fields are present, it checks if `PASSWORD`{.swift} and `CONFIRM_PASSWORD`{.swift} match.
1. If `PASSWORD`{.swift} and `CONFIRM_PASSWORD`{.swift} match, it creates an instance of `UserRegisterCommand`.
1. `Logic Manager` executes `UserRegisterCommand` by calling `UserRegisterCommand#execute()`.
1. `UserRegisterCommand` checks if a user is already registered by calling `Model#getStoredUser`.
1. If no user is registered, `UserRegisterCommand` calls `Model#registerUser` to store the user. Login status is set to
true.
9. `UserRegisterCommand` calls `Model#updateFilteredPersonList` to display the list of customers.
10. `UserRegisterCommand` returns a `CommandResult` with a success message.
1. `UserRegisterCommand` calls `Model#showAllFilteredCustomerList` to display the list of customers.
1. `UserRegisterCommand` returns a `CommandResult` with a success message.

The following sequence diagram shows how the `register` command works:

<puml src="diagrams/UserRegisterSequenceDiagram.puml" alt="UserRegisterSequenceDiagram" />

<br>

<br/>


### List Delivery Feature

Expand Down
4 changes: 2 additions & 2 deletions docs/diagrams/UserRegisterActivityDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ start
if () then ([else])
:ParseException: Invalid Command Format;
stop
([all fields are filled]) elseif () then ([else])
( [all fields are filled]) elseif () then ([else])
:ParseException: Password Mismatch;
stop
([password match confirm password]) elseif () then ([stored user already exists])
( [password match confirm password]) elseif () then ([stored user already exists])
:CommandException: Already Have Account;
stop
else ( [else])
Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/UserRegisterSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ activate Model
Model --> UserRegisterCommand
deactivate Model

UserRegisterCommand -> Model : updateFilteredPersonList(PREDICATE_SHOW_ALL_CUSTOMERS)
UserRegisterCommand -> Model : showAllFilteredCustomerList()
activate Model

Model --> UserRegisterCommand
Expand Down

0 comments on commit 35a4088

Please sign in to comment.