-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add Authentication extra features to Comments tab #41
Merged
Merged
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1e0f882
Change /authentication to send JSON instead of HTML to include user e…
tttzach 7cff3f4
Show email address of user who posted each comment
tttzach 0ffb42b
Merge branch 'master' into LibrariesAuthenticationExtra
tttzach 0f15f74
Fix merge conflict commit
tttzach 0207f37
Use return early pattern
tttzach 7c6f54b
Resolve merge conflict with master
tttzach 62c462a
Use template literals
tttzach 3c02420
Sort imports
tttzach 7e85c56
Use custom Pair class
tttzach 3670eb7
Format according to Codacy suggestions
tttzach daa4204
Format according to Codacy suggestions again
tttzach d1f58d0
Add utility class to centralize sendJson
tttzach b512044
Change name of Pair class to UserInfo class
tttzach 55111cf
Store login status as a boolean
tttzach 316eb68
Remove unnecessary helper functions
tttzach 7b86eaf
Reformat according to Codacy suggestions
tttzach b3b113a
Reformat according to Codacy suggestions again
tttzach 84a0c75
Create separate factory methods for loggedIn and loggedOut
tttzach c858d4f
Add javadoc-style comments to public class and methods
tttzach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
portfolio/src/main/java/com/google/sps/servlets/JsonUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2019 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.sps.servlets; | ||
|
||
import com.google.gson.Gson; | ||
import java.io.IOException; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
public final class JsonUtil { | ||
|
||
public static void sendJson(HttpServletResponse response, Object object) throws IOException { | ||
Gson gson = new Gson(); | ||
String json = gson.toJson(object); | ||
response.getWriter().println(json); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
portfolio/src/main/java/com/google/sps/servlets/UserInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2019 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.sps.servlets; | ||
|
||
public class UserInfo { | ||
|
||
private String email; | ||
private String loginOrLogoutUrl; | ||
private boolean loggedIn; | ||
|
||
UserInfo(String email, String loginOrLogoutUrl, boolean loggedIn) { | ||
this.email = email; | ||
this.loginOrLogoutUrl = loginOrLogoutUrl; | ||
this.loggedIn = loggedIn; | ||
} | ||
|
||
public String getEmail(){ | ||
return email; | ||
} | ||
|
||
public String getLoginOrLogoutUrl(){ | ||
return loginOrLogoutUrl; | ||
} | ||
|
||
public boolean isLoggedIn() { | ||
return loggedIn; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Public classes and methods should have comments.
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.
Thanks! Added the relevant javadoc-style comments for this class. Will go back to the other classes unrelated to this PR here #59
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.
RESOLVED