-
Notifications
You must be signed in to change notification settings - Fork 1
Initial commit: Login UI #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| @Override | ||
| public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
| // Get the value entered in the form. | ||
| String clientName = request.getParameter("clientName"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since clientName and clientPassword are used a few times in this class you can make them static variables. This makes a single copy of the strings and also protects against any potential typos in future uses.
| KeyFactory keyFactory = datastore.newKeyFactory().setKind("Task"); | ||
|
|
||
| // Print the value so you can see it in the server logs. | ||
| System.out.println(clientName + ": " + clientPassword); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the requirements are for this but we may want to reconsider the safety implications of printing the password.
|
|
||
| public Task(long id, String names, String lastNames, String username, | ||
| long timestamp) { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: You can get rid of this empty extra line.
| } | ||
|
|
||
| public String getUsername() { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: You can get rid of this empty extra line.
|
|
||
| // check if the username exists in the database | ||
| boolean existUsername = true; | ||
| for (int i = 0; i < tasks.size(); i++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you can make this more efficient by storing a set or map of usernames and then checking if the username exists there. It would be O(1) runtime instead of O(n) (please reach out if you have further questions about this!)
No description provided.