Skip to content

Commit

Permalink
Update documentation and code base consistency
Browse files Browse the repository at this point in the history
* update user guide , update codebase to be more consistent

* update UserGuide image link

* update user guide

* update Test

* update xref to all ppp .adoc
  • Loading branch information
waynekoo authored Apr 11, 2018
1 parent e7c02f4 commit 45833df
Show file tree
Hide file tree
Showing 20 changed files with 122 additions and 25 deletions.
99 changes: 85 additions & 14 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,25 @@ eg. `list` and `l` will both show a list of all employees in PTMan.
As a manager, you are able to access these commands in addition to the <<General Commands, general commands>>.
These manager commands require logging in to <<Admin Mode, admin mode>> as shown in <<Logging in to admin mode: `login`>>.

// tag::accessControl[]

[[Login]]
==== Logging in to admin mode: `login`
Logs in to <<Admin Mode, admin mode>>, allowing you to use all the manager commands.

*Format:* `login pw/AdminPassword`

// TODO: SCREENSHOT
*Format:* `login pw/ADMIN_PASSWORD`

You can key in the command with your password as shown in _<<fig-Login>>_.
[[fig-Login]]
.Logging in in PTMan +
image::loginPassword.png[width="790"]

Once you are logged in, a admin mode icon will appear to indicate that you are in admin mode as shown in _<<fig-LoginSuccess>>_.

[[fig-LoginSuccess]]
.logged in in PTMan +
image::loginSuccess.png[width="790"]

[IMPORTANT]
Please remember to logout when you are done to prevent unauthorized access to manager commands. +
Expand All @@ -229,39 +241,73 @@ Logs out of <<Admin Mode, admin mode>>, preventing further usage of manager feat

*Format:* `logout`

You can key in the command to log out as shown in _<<fig-loggingOut>>_.
[[fig-loggingOut]]
.Logging out in PTMan +
image::logout.png[width="790"]

After `logout` is executed, the admin icon will disappear from the command box as shown in _<<fig-logoutSuccess>>_.

[[fig-logoutSuccess]]
.Logged out in PTMan +
image::loginNoAdminIcon.png[width="790"]

[[Cap]]
==== Changing the admin password: `changeadminpw`
Changes the <<Admin Mode, admin mode>> password.

*Format:* `changeadminpw pw/CURRENT_PASSWORD pw/NEW_PASSWORD pw/CONFIRM_NEW_PASSWORD` +
*Shorthand:* `cap`
*Shorthand:* `cap` `pw/CURRENT_PASSWORD pw/NEW_PASSWORD pw/CONFIRM_NEW_PASSWORD`

[IMPORTANT]
To prevent unauthorized access to admin mode, managers should execute this command upon running PTMan for the first time.

// TODO: SCREENSHOT
Examples:

* If the current admin password is `DEFAULT1` and you wish to change it to `hunter2`, type: +
`changeadminpw pw/DEFAULT1 pw/hunter2 pw/hunter2`
* If the current admin password is `AdminPw` and you wish to change it to `Iamtheadmin`, type: +
`changeadminpw pw/AdminPw pw/Iamtheadmin pw/Iamtheadmin`

If the current admin password is `DEFAULT1` and you wish to change it to `hunter2`, type:
`changeadminpw pw/DEFAULT1 pw/hunter22 pw/hunter22` which will be masked by asterisks in the program as shown in _<<fig-changingAdminPassword>>_.

[[fig-changingAdminPassword]]
.Changing admin password in PTMan +
image::changingAdminPassword.png[width="790"]

After password is changed successfully, a notification will be displayed below the command box as shown in _<<fig-changedAdminPassword>>_.

[[fig-changedAdminPassword]]
.Admin password changed in PTMan +
image::changedAdminPassword.png[width="790"]

[NOTE]
The password should be at least 8 characters long.
The password should be at least 8 characters long. +
The sequence of current and new password entered must be of the format.

[[Rap]]
==== Resetting the admin password: `resetadminpw`

Resets your <<Admin Mode, admin mode>> password and sends a randomly generated password to the outlet's email address. +
You may use the new password to login to admin mode to change the password.

// TODO: SCREENSHOT + EMAIL SCREENSHOT
*Format:* `resetadminpw` +
*Shorthand:* `rap`

You can key in the command to reset admin password as shown in _<<fig-resetAdminPassword>>_

[[fig-resetAdminPassword]]
.Resetting admin password in PTMan +
image::resetAdminPassword.png[width="790"]

After the command is executed successfully, a notification will be displayed as shown in _<<fig-resetAdminPasswordSuccess>>_.


[[fig-resetAdminPasswordSuccess]]
.Reset admin password in PTMan +
image::resetAdminPasswordSuccess.png[width="790"]


[NOTE]
The temporary password will be sent to the outlet's email.
The temporary password will be sent to the outlet's email stored in PTMan.

// end::accessControl[]

[[Add]]
==== Adding an employee: `add`
Expand All @@ -286,7 +332,9 @@ image::Ui_add1.png[width="790"]

. Click kbd:[Enter] and you would see a confirmation message below the command bar, and John Doe being added into your Employee list.
_<<fig-Add2>>_ shows how PTMan should look like after the above command.

+

[[fig-Add2]]
.Successful addition of employee into PTMan +
image::Ui_add2.png[width="790"]
Expand All @@ -299,6 +347,28 @@ More Examples:
* To add an employee named `Betsy Crowe` with email `[email protected]`, address `Newgate Prison`, phone number `1234567`, and salary of $`100`, type: +
`add n/Betsy Crowe e/[email protected] a/Newgate Prison p/1234567 s/100`

[[AddSalary]]
==== Adding salary to an employee: `addsalary`
Adds an existing employee's salary by an amount.

*Format:* `addsalary INDEX s/SALARY_INCREASE_BY` +
*Shorthand:* `adds` `INDEX s/SALARY_INCREASE_BY`

You can increase an employer salary by an amount as shown below in _<<fig-addingSalary>>_.

[[fig-addingSalary]]
.Adding salary for employee in PTMan +
image::addingSalary.png[width="790"]

After you executed the command, you will see the result from the result display and the applied salary as shown in _<<fig-addSalarySuccess>>_.

[[fig-addSalarySuccess]]
.Adding salary for employee in PTMan +
image::addSalarySuccess.png[width="790"]

[NOTE]
An employee's salary can not be deducted from using this command.

[[Edit]]
==== Editing an employee: `edit`

Expand Down Expand Up @@ -660,11 +730,12 @@ Examples:
// end::shiftemployee[]

[[Cp]]
==== Changing your employee password: `cp`
==== Changing your employee password: `changepw`
Changes your employee password.
For security purposes, you are highly encouraged to change your password the moment your account is created. +

*Format:* `cp INDEX pw/CURRENT_PASSWORD pw/NEW_PASSWORD pw/CONFIRM_NEW_PASSWORD`
*Format:* `changepw INDEX pw/CURRENT_PASSWORD pw/NEW_PASSWORD pw/CONFIRM_NEW_PASSWORD` +
*Shorthand:* `cp` `INDEX pw/CURRENT_PASSWORD pw/NEW_PASSWORD pw/CONFIRM_NEW_PASSWORD`

****
* The `INDEX` refers to the index number shown in the most recent employee listing.
Expand Down
Binary file added docs/images/addSalarySuccess.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/addingSalary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/changedAdminPassword.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/changingAdminPassword.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/loginNoAdminIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/loginPassword.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/loginSuccess.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/logout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/resetAdminPassword.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/resetAdminPasswordSuccess.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/team/SunBangJie.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
= Sun Bangjie - Project Portfolio
:imagesDir: ../images
:stylesDir: ../stylesheets
:xrefstyle: short

== PROJECT: Part-time Manager (PTMan)

Expand Down
1 change: 1 addition & 0 deletions docs/team/hzxcaryn.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
= Caryn Heng - Project Portfolio
:imagesDir: ../images
:stylesDir: ../stylesheets
:xrefstyle: short

== PROJECT: Part-time Manager (PTMan)

Expand Down
13 changes: 7 additions & 6 deletions docs/team/koo1993.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
= Koo Chin Chye - Project Portfolio
:imagesDir: ../images
:stylesDir: ../stylesheets
:xrefstyle: short

== PROJECT: Part-time Manager (PTMan)

Expand All @@ -16,23 +17,23 @@ The user interacts with the application using a CLI, and it has a GUI created wi
== Summary of contributions

* *Major enhancement*: Added *access control* that manages functions for employer and employee. [https://github.com/CS2103JAN2018-W14-B2/main/issues/39[Issue #39]]
** What it does: Each employer and employee is assigned to a password. This restrict employee to use function that are meant for the employe.
** What it does: Each employer and employee is assigned to a password. This restrict employee to use functions that are meant for the employer.
** What it includes:
*** Admin commands are restricted to employer only.
*** API for password checking for commands that need password.
*** Login/Logout to admin mode for employer to use admin command at ease.
*** Change/reset password are available for both group of user with email service.
*** API for password checking that need password.
*** Login/Logout to admin mode for employer to use admin commands at ease.
*** Change/reset password is available for both group of user with email service.
** Justification: This ensure only authenticated personnel can use the system and prevent misuse of PTMan.


* *Minor enhancement*: Added salary parameter and add salary command so that employer can manage employees' pay.
* *Minor enhancement*: Added salary parameter and addsalary command for employer to manage employees' pay.

* *Code contributed*: [https://github.com/CS2103JAN2018-W14-B2/main/blob/master/collated/functional/koo1993.md[Functional code]] [https://github.com/CS2103JAN2018-W14-B2/main/blob/master/collated/test/koo1993.md[Test code]]

* *Other contributions*:

** Project management:
*** Constantly collating the update from the team and call for meeting if there is a need to.
*** Constantly collate updates from the team and call for meeting if there is a need to.
** Enhancements to existing features:
*** Implemented obfuscation for password in input text field and history. (Pull requests https://github.com/CS2103JAN2018-W14-B2/main/pull/132[#132], https://github.com/CS2103JAN2018-W14-B2/main/pull/141[#141], https://github.com/CS2103JAN2018-W14-B2/main/pull/157[#157])
*** Wrote email service to send reset password to employer and employee via email. (Pull requests https://github.com/CS2103JAN2018-W14-B2/main/pull/113[#113])
Expand Down
1 change: 1 addition & 0 deletions docs/team/shannonwong.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
= Shannon Wong - Project Portfolio
:imagesDir: ../images
:stylesDir: ../stylesheets
:xrefstyle: short

== PROJECT: Part-Time Manager (PTMan)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.ptman.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.ptman.commons.core.Messages.MESSAGE_ACCESS_DENIED;

import java.util.ArrayList;

Expand All @@ -27,7 +28,7 @@ public class ChangeAdminPasswordCommand extends Command {
+ COMMAND_FORMAT
+ "\nExample: "
+ "pw/DEFAULT1 "
+ "pw/hunter1 " + "pw/hunter1";
+ "pw/hunter22 " + "pw/hunter22";


public static final String MESSAGE_INVALID_CONFIMREDPASSWORD = "New password entered are not the same.";
Expand All @@ -48,6 +49,9 @@ public ChangeAdminPasswordCommand(ArrayList<String> passwords) {

@Override
public CommandResult execute() throws CommandException {
if (!model.isAdminMode()) {
throw new CommandException(MESSAGE_ACCESS_DENIED);
}

checkConfirmedPassword(passwords.get(1), passwords.get(2));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class ChangePasswordCommand extends Command {
+ "\nExample: "
+ "1 "
+ "pw/DEFAULT1 "
+ "pw/hunter1 " + "pw/hunter1";
+ "pw/hunter22 " + "pw/hunter22";


public static final String MESSAGE_INVALID_CONFIMREDPASSWORD = "New password entered are not the same";
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/seedu/ptman/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ public boolean isAdminMode() {
@Override
public synchronized boolean setTrueAdminMode(Password password) {
requireNonNull(password);
if (!partTimeManager.isAdminPassword(password)) {
if (!partTimeManager.isAdminPassword(password)
&& !isCorrectTempPwd(partTimeManager.getOutletInformation(), password)) {
return false;
}
partTimeManager.setAdminMode(partTimeManager.isAdminPassword(password));
partTimeManager.setAdminMode(true);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/ptman/model/employee/Salary.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class Salary {

public static final String MESSAGE_SALARY_CONSTRAINTS =
"Salary can only contain positive numbers";
"Salary can only contain positive Integer";
public static final String SALARY_VALIDATION_REGEX = "^[0-9]\\d*$";
public final String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static seedu.ptman.commons.core.Messages.MESSAGE_ACCESS_DENIED;
import static seedu.ptman.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.ptman.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.ptman.testutil.TypicalEmployees.getTypicalPartTimeManager;
import static seedu.ptman.testutil.TypicalIndexes.INDEX_FIRST_EMPLOYEE;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand All @@ -34,6 +36,21 @@ public class ChangeAdminPasswordCommandTest {
public ExpectedException thrown = ExpectedException.none();
private Model model = new ModelManager(getTypicalPartTimeManager(), new UserPrefs(), new OutletInformation());

@Before
public void setup() {
model.setTrueAdminMode(new Password());
}

@Test
public void execute_notAdminModeValidInputs_accessDenied() {
model.setFalseAdminMode();
ArrayList<String> passwords = new ArrayList<>();
passwords.add("DEFAULT1");
passwords.add("DEFAULT2");
passwords.add("DEFAULT2");
assertCommandFailure(prepareCommand(passwords), model, MESSAGE_ACCESS_DENIED);
}

@Test
public void execute_validInputs_success() throws Exception {
Employee employeeToEdit = model.getFilteredEmployeeList().get(INDEX_FIRST_EMPLOYEE.getZeroBased());
Expand Down

0 comments on commit 45833df

Please sign in to comment.