*/
protected void registerUser() throws BadRequestException, SQLException, IOException {
final Request req = getRequest();
final Locale locale = getLocale();
final Properties p = getProperties();
final String name = req.getArgument( "name" ).trim();
final String pass1 = req.getArgument( "pass1" );
final String pass2 = req.getArgument( "pass2" );
final String email = req.getArgument( "email" ).trim();
final Database db = getDatabase();
final Validater v = new Validater( db );
if ( !v.checkRequiredFields(new String[]{name,pass1,email}) )
throw new BadRequestException( locale.getString("www.error.missingField") );
if ( !pass1.equals(pass2) )
throw new BadRequestException( locale.getString("www.error.passwordsDontMatch") );
if ( !v.isValidEmail(email) )
throw new BadRequestException( locale.getString("www.error.invalidEmail") );
if ( v.usernameExists(name) )
throw new BadRequestException( locale.getString("www.error.duplicateUsername") );
if ( v.emailExists(email) )
throw new BadRequestException( locale.getString("www.error.duplicateEmail") );
User newUser = new User( -1, name, pass1, email );
newUser.setActive( !p.get(Constants.WWW_USERS_REQUIRE_ACTIVATION).equals(Properties.YES) );
newUser.save( db );