@@ -85,27 +85,28 @@ public void validate(Object obj, Errors errors) {
85
85
if (person .getPersonName () == null || StringUtils .isEmpty (person .getPersonName ().getFullName ()))
86
86
errors .rejectValue ("person" , "Person.names.length" );
87
87
}
88
- }
89
- AdministrationService as = Context .getAdministrationService ();
90
- boolean emailAsUsername = false ;
91
- try {
92
- Context .addProxyPrivilege (PrivilegeConstants .GET_GLOBAL_PROPERTIES );
93
- emailAsUsername = Boolean .parseBoolean (as .getGlobalProperty (
94
- OpenmrsConstants .GLOBAL_PROPERTY_USER_REQUIRE_EMAIL_AS_USERNAME , "false" ));
95
- }
96
- finally {
97
- Context .removeProxyPrivilege (PrivilegeConstants .GET_GLOBAL_PROPERTIES );
98
- }
99
-
100
- if (emailAsUsername ) {
101
- boolean isValidUserName = isUserNameAsEmailValid (user .getUsername ());
102
- if (!isValidUserName ) {
103
- errors .rejectValue ("username" , "error.username.email" );
88
+
89
+ AdministrationService as = Context .getAdministrationService ();
90
+ boolean emailAsUsername = false ;
91
+ try {
92
+ Context .addProxyPrivilege (PrivilegeConstants .GET_GLOBAL_PROPERTIES );
93
+ emailAsUsername = Boolean .parseBoolean (as .getGlobalProperty (
94
+ OpenmrsConstants .GLOBAL_PROPERTY_USER_REQUIRE_EMAIL_AS_USERNAME , "false" ));
104
95
}
105
- } else {
106
- boolean isValidUserName = isUserNameValid (user .getUsername ());
107
- if (!isValidUserName ) {
108
- errors .rejectValue ("username" , "error.username.pattern" );
96
+ finally {
97
+ Context .removeProxyPrivilege (PrivilegeConstants .GET_GLOBAL_PROPERTIES );
98
+ }
99
+
100
+ if (emailAsUsername ) {
101
+ boolean isValidUserName = isUserNameAsEmailValid (user .getUsername ());
102
+ if (!isValidUserName ) {
103
+ errors .rejectValue ("username" , "error.username.email" );
104
+ }
105
+ } else {
106
+ boolean isValidUserName = isUserNameValid (user .getUsername ());
107
+ if (!isValidUserName ) {
108
+ errors .rejectValue ("username" , "error.username.pattern" );
109
+ }
109
110
}
110
111
}
111
112
}
1 commit comments
djazayeri commentedon Jan 2, 2014
Remember to include ticket numbers in your commit comments. :-)