-
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
9-feature-1-user-registration #17
Open
parmism
wants to merge
25
commits into
main
Choose a base branch
from
9-feature-1-user-registration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e71f7da
Minor Changes, just added some of the objects which I will implement …
Madhavan7 26632a1
Added a few methods, pending implementation
Madhavan7 0b25139
Added the required objects and wrote some code
Madhavan7 cb07aea
Wrote some code for the UI
Madhavan7 33eab38
Almost done implementation of UserRegistrationUI and UserVerificationUI
Madhavan7 b8f86ab
Minor changes
Madhavan7 e4efd7e
added changes made to another branch and brought it here
Madhavan7 5c4b5c9
added changes made to another branch and resolved conflicts
Madhavan7 bf8afc7
Made changes to UserRegistrationUI and UserVerificationUI the only is…
Madhavan7 a2a33b7
When tested using "TestUserDatabase3.csv" everything seems to work
Madhavan7 f837d19
Used Factory design pattern to change the method "sendVerificationCod…
Madhavan7 9c471f0
Figured out and corrected the bug in UserDatabase.createUser now its …
Madhavan7 776765e
Made changes to the gradle dependencies in order to facilitate email …
Madhavan7 f19fb12
Packaged all the files
Madhavan7 2f00f3a
There was design problems with user verification, so I changed the de…
Madhavan7 45271e7
Implemented Email verification
Madhavan7 bf563b5
Changed the Packaging Structure
Madhavan7 bbd6f94
Minor Changes
Madhavan7 73d358a
Merge branch 'main' into 9-feature-1-user-registration
Madhavan7 1007a1e
Minor Changes
Madhavan7 1da907a
Minor Changes
Madhavan7 705b6c9
Minor Changes
Madhavan7 6e91e27
Minor Changes
Madhavan7 a86bb7d
Merged conflicts from the main branch
Madhavan7 a6d0b75
Merged conflicts from the main branch
Madhavan7 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
Binary file not shown.
4 changes: 3 additions & 1 deletion
4
src/main/java/BasicUser.java → ...ava/Entities/user_entities/BasicUser.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
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
2 changes: 2 additions & 0 deletions
2
src/main/java/UserFactory.java → ...a/Entities/user_entities/UserFactory.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
Empty file.
2 changes: 2 additions & 0 deletions
2
src/main/java/Changeable.java → src/main/java/UseCase/Changeable.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package UseCase; | ||
|
||
public interface Changeable { | ||
void changeFeature(String feature, String newFeature); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
2 changes: 2 additions & 0 deletions
2
src/main/java/IRetrieveList.java → ...ava/interface_adapters/IRetrieveList.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
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,8 @@ | ||
package interface_adapters; | ||
|
||
import Entities.user_entities.User; | ||
import interface_adapters.user_registration_interface_adapters.UserExists; | ||
|
||
public interface UserRetriever extends UserExists { | ||
User getUser(String username); | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/UserExists.java → ...ration_interface_adapters/UserExists.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package interface_adapters.user_registration_interface_adapters; | ||
|
||
public interface UserExists { | ||
boolean UserExists(String username, String password); | ||
} |
116 changes: 116 additions & 0 deletions
116
...a/interface_adapters/user_registration_interface_adapters/UserRegistrationController.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,116 @@ | ||
package interface_adapters.user_registration_interface_adapters; | ||
|
||
import use_cases.user_login_use_case.UserCreator; | ||
import use_cases.user_login_use_case.verificationMethodFactory; | ||
|
||
import javax.swing.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.util.Random; | ||
public class UserRegistrationController implements UserVerifier, ActionListener, UserRegistrator { | ||
private final String username; | ||
private final String password; | ||
private final String email; | ||
private String preference; | ||
private boolean userExists = false; | ||
private UserCreator database; | ||
Random random; | ||
private final int code; | ||
private JTextField verificationCodeText; | ||
private JLabel success; | ||
|
||
/*public UserRegistrationController(int code, String Username, String Password, String email, UserDatabase database){ | ||
this.code = code; | ||
this.username = Username; | ||
this.password = Password; | ||
this.email = email; | ||
this.database = database; | ||
}*/ | ||
|
||
public UserRegistrationController(UserRegistrationGateway properties){ | ||
this.username = properties.getUsername(); | ||
this.password = properties.getPassword(); | ||
this.email = properties.getEmail(); | ||
this.userExists = properties.isUserExists(); | ||
this.code = properties.getCode(); | ||
this.database = properties.getDatabase(); | ||
} | ||
|
||
//Asks for the verification code from the user, and matches it with this.code to potentially verify the user | ||
public void verify(String email){ | ||
JFrame verificationFrame = new JFrame(); | ||
verificationFrame.setSize(400, 200); | ||
verificationFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); | ||
JPanel verificationPanel = new JPanel(); | ||
verificationFrame.add(verificationPanel); | ||
|
||
verificationPanel.setLayout(null); | ||
JLabel verificationLabel = new JLabel("Verification Code"); | ||
verificationLabel.setBounds(10,25, 200, 25); | ||
verificationCodeText = new JTextField(); | ||
verificationCodeText.setBounds(125, 20, 165, 25); | ||
|
||
verificationPanel.add(verificationLabel); | ||
verificationPanel.add(verificationCodeText); | ||
|
||
//Success/Failure Labels | ||
success = new JLabel(""); | ||
success.setBounds(10, 50, 100, 25); | ||
verificationPanel.add(success); | ||
|
||
JButton verifyButton = new JButton("verify"); | ||
verifyButton.setBounds(125, 50, 100, 25); | ||
verificationPanel.add(verifyButton); | ||
verifyButton.addActionListener(this); | ||
verificationFrame.setVisible(true); | ||
|
||
verificationMethodFactory mailMan = new verificationMethodFactory(email, "Email", code); | ||
mailMan.deliverCode(); | ||
} | ||
|
||
public void registerUser() { | ||
if(this.userExists){ | ||
System.out.println("An account with this username or email already exists"); | ||
accountExistsMessage(); | ||
}else{ | ||
this.verify(email); | ||
} | ||
} | ||
|
||
public static void accountExistsMessage(){ | ||
JFrame accountExistsFrame = new JFrame(); | ||
accountExistsFrame.setSize(400, 100); | ||
accountExistsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); | ||
JPanel accountExistsPanel = new JPanel(); | ||
accountExistsPanel.setLayout(null); | ||
accountExistsFrame.add(accountExistsPanel); | ||
JLabel errorMessage = new JLabel("An account with this username or email already exists"); | ||
errorMessage.setBounds(10,20, 350, 20); | ||
accountExistsPanel.add(errorMessage); | ||
accountExistsFrame.setVisible(true); | ||
} | ||
|
||
public static void verificationSuccessMessage(){ | ||
JFrame verificationSuccessFrame = new JFrame(); | ||
verificationSuccessFrame.setSize(400, 100); | ||
verificationSuccessFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); | ||
JPanel verificationSuccessPanel = new JPanel(); | ||
verificationSuccessPanel.setLayout(null); | ||
verificationSuccessFrame.add(verificationSuccessPanel); | ||
JLabel errorMessage = new JLabel("Could not verify please try again"); | ||
errorMessage.setBounds(10,20, 350, 20); | ||
verificationSuccessPanel.add(errorMessage); | ||
verificationSuccessFrame.setVisible(true); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
int verCode = Integer.parseInt(verificationCodeText.getText()); | ||
if(verCode == this.code){ | ||
database.createUser(this.username, this.password, this.email, "Basic"); | ||
System.out.println("Verification successful"); | ||
}else{ | ||
verificationSuccessMessage(); | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...java/interface_adapters/user_registration_interface_adapters/UserRegistrationGateway.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,62 @@ | ||
package interface_adapters.user_registration_interface_adapters; | ||
|
||
import use_cases.user_login_use_case.UserCreator; | ||
|
||
public class UserRegistrationGateway { | ||
private String username; | ||
private String password; | ||
private String email; | ||
private boolean userExists = false; | ||
private int code; | ||
private UserCreator database; | ||
|
||
private String preference; | ||
|
||
public void setUsername(String username){ | ||
this.username = username; | ||
} | ||
public String getUsername(){ | ||
return this.username; | ||
} | ||
|
||
public void setPassword(String password){ | ||
this.password = password; | ||
} | ||
public String getPassword(){ | ||
return this.password; | ||
} | ||
|
||
public void setEmail(String email){ | ||
this.email = email; | ||
} | ||
public String getEmail(){ | ||
return this.email; | ||
} | ||
|
||
public void setUserExists(boolean userExists) { | ||
this.userExists = userExists; | ||
} | ||
|
||
public boolean isUserExists() { | ||
return userExists; | ||
} | ||
|
||
public int getCode() { | ||
return code; | ||
} | ||
public void setCode(int code){ | ||
this.code = code; | ||
} | ||
|
||
public void setDatabase(UserCreator database) { | ||
this.database = database; | ||
} | ||
|
||
public UserCreator getDatabase(){ | ||
return this.database; | ||
} | ||
|
||
public void setPreference(String preference) { | ||
this.preference = preference; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/interface_adapters/user_registration_interface_adapters/UserRegistrator.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,5 @@ | ||
package interface_adapters.user_registration_interface_adapters; | ||
|
||
public interface UserRegistrator { | ||
void registerUser(); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/interface_adapters/user_registration_interface_adapters/UserVerifier.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,5 @@ | ||
package interface_adapters.user_registration_interface_adapters; | ||
|
||
public interface UserVerifier { | ||
void verify(String email); | ||
} |
Oops, something went wrong.
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.
I think it is correct to delete this while loop since it is not necessary