From 2980956e764d496a91ff8a917570c87a7677d0f0 Mon Sep 17 00:00:00 2001 From: jianyangg Date: Sat, 11 Nov 2023 20:17:01 +0800 Subject: [PATCH] Update DG (JY) Updated implementation for register account in terms of: * Sequence diagram * Activity diagram * Their descriptive text --- docs/DeveloperGuide.md | 76 +++++++++---------- .../diagrams/UserRegisterActivityDiagram.puml | 4 +- .../diagrams/UserRegisterSequenceDiagram.puml | 2 +- 3 files changed, 38 insertions(+), 44 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index d3642f8435e..effd06eeb25 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -225,15 +225,16 @@ Classes used by multiple components are in the `seedu.addressbook.commons` packa This section describes some noteworthy details on how certain features are implemented. -- [Update Delivery Status](#update-delivery-status-feature) -- [Create Delivery Note](#create-note-for-delivery-feature) -- [User Register Account Command](#user-register-account-command) -- [User Login](#user-login-command) -- User Update Details -- [User Logout](#user-logout-command) -- User Account Recovery -- User Account Deletion -- [Add Customer](#add-customer-command) +* [Update Delivery Status Feature](#update-delivery-status-feature) +* [Create Note for Delivery Feature](#create-note-for-delivery-feature) +* [User Register Account Command](#user-register-account-command) +* [List Delivery Feature](#list-delivery-feature) +* [View Delivery Feature](#view-delivery-feature) +* [User Login Command](#user-login-command) +* [User Logout Command](#user-logout-command) +* [Add Customer Command](#add-customer-command) +* [Customer Edit Command](#customer-edit-command) +* [Delivery Add Command](#delivery-add-command) ### Update Delivery Status Feature @@ -282,18 +283,6 @@ The following sequence diagram illustrates the `delivery status` command sequenc -This section describes some noteworthy details on how certain features are implemented. - -- [Create Delivery Note](#create-note-for-delivery-feature) -- [User Register Account Command](#user-register-account-command) -- [User Login Command](#user-login-command) -- User Update Details Command -- [User Logout Command](#user-logout-command) -- User Account Recovery -- User Account Deletion -- Customer Edit Command -- Delivery Add Command - ### Create Note for Delivery Feature #### Overview @@ -345,7 +334,7 @@ The following diagram illustrates the `delivery note` command sequence: -### User Register Account Command +###
User Register Account Command **Overview:** The `register` command is used to register a new user account. @@ -355,16 +344,18 @@ 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: @@ -372,24 +363,27 @@ The following activity diagram shows the logic of a user registering an account: 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: +
+ ### List Delivery Feature ### Overview diff --git a/docs/diagrams/UserRegisterActivityDiagram.puml b/docs/diagrams/UserRegisterActivityDiagram.puml index af895167b4c..56e507b28d6 100644 --- a/docs/diagrams/UserRegisterActivityDiagram.puml +++ b/docs/diagrams/UserRegisterActivityDiagram.puml @@ -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]) diff --git a/docs/diagrams/UserRegisterSequenceDiagram.puml b/docs/diagrams/UserRegisterSequenceDiagram.puml index e1a4bf147bf..733789a7e6a 100644 --- a/docs/diagrams/UserRegisterSequenceDiagram.puml +++ b/docs/diagrams/UserRegisterSequenceDiagram.puml @@ -84,7 +84,7 @@ activate Model Model --> UserRegisterCommand deactivate Model -UserRegisterCommand -> Model : updateFilteredPersonList(PREDICATE_SHOW_ALL_CUSTOMERS) +UserRegisterCommand -> Model : showAllFilteredCustomerList() activate Model Model --> UserRegisterCommand