Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Finished error checking.

  • Loading branch information...
commit 3512084d3d9388e52ea971380104c6a7da132d08 1 parent f7fde6a
@dabinett dabinett authored
View
BIN  gwt-unitCache/gwt-unitCache-00000136D73FB49F
Binary file not shown
View
BIN  gwt-unitCache/gwt-unitCache-00000136D742C83E
Binary file not shown
View
BIN  gwt-unitCache/gwt-unitCache-00000136D749D07C
Binary file not shown
View
0  gwt-unitCache/gwt-unitCache-00000136D74D13B3
No changes.
View
2  src/edu/unlv/cs/whoseturn/server/UsersServiceImpl.java
@@ -110,7 +110,7 @@ public String addNewUser(String username, String email, Boolean admin)
{
return errorMessage;
}
-
+
// A Valid username will return "Valid"
// An invalid username will return "Invalid username"
// A duplicate username will return "Username already exists"
View
25 src/edu/unlv/cs/whoseturn/shared/FieldVerifier.java
@@ -43,10 +43,11 @@ public static String isEmailValid(String email)
return errorMessage;
}
+
+ // The following checks for a duplicate email address in the database of current users
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(edu.unlv.cs.whoseturn.domain.User.class);
- //List<String[]> resultStringList = new ArrayList<String[]>();
List<edu.unlv.cs.whoseturn.domain.User> results;
results = (List<edu.unlv.cs.whoseturn.domain.User>) query.execute();
@@ -54,7 +55,7 @@ public static String isEmailValid(String email)
{
for (edu.unlv.cs.whoseturn.domain.User e : results)
{
- if (email == e.getEmail())
+ if (email.equals(e.getEmail()))
{
errorMessage = "Email already exists";
return errorMessage;
@@ -72,6 +73,7 @@ public static String isEmailValid(String email)
* @param username the username to validate
* @return true if valid, false if invalid
*/
+ @SuppressWarnings("unchecked")
public static String isUsernameValid(String username)
{
// The username can't be less than 3 characters
@@ -87,6 +89,25 @@ public static String isUsernameValid(String username)
errorMessage = "Username must be under 30 characters";
return errorMessage;
}
+
+ // The following checks for a duplicate username in the database of current users
+ PersistenceManager pm = PMF.get().getPersistenceManager();
+ Query query = pm.newQuery(edu.unlv.cs.whoseturn.domain.User.class);
+
+ List<edu.unlv.cs.whoseturn.domain.User> results;
+
+ results = (List<edu.unlv.cs.whoseturn.domain.User>) query.execute();
+ if (!results.isEmpty())
+ {
+ for (edu.unlv.cs.whoseturn.domain.User e : results)
+ {
+ if (username.equals(e.getUsername()))
+ {
+ errorMessage = "Username already exists";
+ return errorMessage;
+ }
+ }
+ }
// If we're here, the username is new and within the specified bounds
errorMessage = "Valid";
View
2  war/WEB-INF/appengine-generated/datastore-indexes-auto.xml
@@ -1,4 +1,4 @@
-<!-- Indices written at Sat, 21 Apr 2012 22:26:15 UTC -->
+<!-- Indices written at Sat, 21 Apr 2012 16:47:51 PDT -->
<datastore-indexes/>
View
BIN  war/WEB-INF/appengine-generated/local_db.bin
Binary file not shown
View
BIN  war/WEB-INF/classes/edu/unlv/cs/whoseturn/shared/FieldVerifier.class
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.