Skip to content

Commit

Permalink
User display names MUST be unique
Browse files Browse the repository at this point in the history
  • Loading branch information
rxdps93 committed Apr 30, 2019
1 parent 996da04 commit 273b6df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.dom.freeman.obj.users.UserGroup;
import com.dom.freeman.obj.users.UserOperation;
import com.dom.freeman.utils.FileIO;
import com.dom.freeman.utils.Global;
import com.dom.freeman.utils.Utility;
import com.googlecode.lanterna.gui2.dialogs.MessageDialogBuilder;
import com.googlecode.lanterna.gui2.dialogs.MessageDialogButton;
Expand Down Expand Up @@ -45,6 +46,17 @@ public boolean validateUser() {
.setExtraWindowHints(Arrays.asList(Hint.CENTERED))
.addButton(MessageDialogButton.OK).build().showDialog(this.getTextGUI());
valid = false;
} else {
for (User user : Global.OBJECTS.getUsers()) {
if (user.getDisplayName().equalsIgnoreCase(this.getDisplayNameEntry().getText())) {
new MessageDialogBuilder().setTitle("Create User Validation")
.setText("That display name already exists. It must be unique.")
.setExtraWindowHints(Arrays.asList(Hint.CENTERED))
.addButton(MessageDialogButton.OK).build().showDialog(this.getTextGUI());
valid = false;
break;
}
}
}

return valid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.dom.freeman.obj.users.User;
import com.dom.freeman.obj.users.UserOperation;
import com.dom.freeman.utils.FileIO;
import com.dom.freeman.utils.Global;
import com.dom.freeman.utils.Utility;
import com.googlecode.lanterna.gui2.dialogs.MessageDialogBuilder;
import com.googlecode.lanterna.gui2.dialogs.MessageDialogButton;
Expand Down Expand Up @@ -52,6 +53,17 @@ public boolean validateUser() {
.setExtraWindowHints(Arrays.asList(Hint.CENTERED))
.addButton(MessageDialogButton.OK).build().showDialog(this.getTextGUI());
valid = false;
} else {
for (User user : Global.OBJECTS.getUsers()) {
if (user.getDisplayName().equalsIgnoreCase(this.getDisplayNameEntry().getText())) {
new MessageDialogBuilder().setTitle("Create User Validation")
.setText("That display name already exists. It must be unique.")
.setExtraWindowHints(Arrays.asList(Hint.CENTERED))
.addButton(MessageDialogButton.OK).build().showDialog(this.getTextGUI());
valid = false;
break;
}
}
}

return valid;
Expand Down

0 comments on commit 273b6df

Please sign in to comment.