Commit cda0d177 authored by Oskars's avatar Oskars
Browse files

Change: minor changes added, fixed login

parent b2fc1663
......@@ -12,7 +12,7 @@ import model.PostType;
public class main {
public static void main(String[] args) {
System.out.println(Encryption.encryptMD5("RightPassword"));
// CREATE PRIVATE USER, POST
PrivateUser privateUser1 = new PrivateUser("Oskars Birgelis", "Oskars", "RightPassword", null, null);
PrivateUser privateUser2 = new PrivateUser("Peteris Petersons", "Peteris", "Petersons", null, null);
......@@ -56,12 +56,8 @@ public class main {
//System.out.println(privateUser1.findPublicPostInPage("Mathematics"));
//REGISTER, LOGIN (register is User object creation - skipping it)
System.out.println((privateUser1.login("WrongPassword"))? "Logged in" : "Wrong password");
System.out.println((privateUser1.login("RightPassword"))? "Logged in" : "Wrong password");
System.out.println(Encryption.encryptMD5("RightPassword"));
System.out.println(Encryption.encryptMD5("RightPassword"));
System.out.println( (privateUser1.login("WrongPassword"))? "Logged in" : "Wrong password" );
System.out.println( (privateUser1.login("RightPassword"))? "Logged in" : "Wrong password" );
}
......
......@@ -25,7 +25,7 @@ public abstract class User extends GuestUser implements IPost{
nameAndSurname = "Empty";
username = "Empty";
password = "Empty";
generatedPassword = null;
generatedPassword = Encryption.encryptMD5("Empty");
allUsers.add(this);
}
......@@ -33,6 +33,7 @@ public abstract class User extends GuestUser implements IPost{
super();
this.nameAndSurname = (Verification.verificateNameAndSurname(nameAndSurname))? nameAndSurname : "Empty";
this.username = (Verification.verificateUsername(username))? username : "Empty";
if(Verification.verificatePassword(password)) {
this.password = password;
generatedPassword = Encryption.encryptMD5(password);
......@@ -65,11 +66,6 @@ public abstract class User extends GuestUser implements IPost{
}
}
// public void setAllUsers(ArrayList<User> userList) {
// allUsers = (userList != null) ? userList : new ArrayList<User>();
// }
//GETTERS
public String getNameAndSurname() {
......@@ -98,7 +94,7 @@ public abstract class User extends GuestUser implements IPost{
}
public boolean login(String inputPassword) {
return (generatedPassword == Encryption.encryptMD5(inputPassword))? true : false;
return (generatedPassword.intern() == (Encryption.encryptMD5(inputPassword)).intern() )? true : false;
}
public boolean followPage(Page page) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment