示例#1
0
 if (strlen($form->inputEmail) > 0) {
     $form->addValidator(new EmailValidator('inputEmail', true, 'Please provide a valid e-mail address'));
     $form->addValidator(new MatchValidator('inputEmail', 'inputEmailVerify', true, 'Email Addresses must match '));
     $form->addValidator(new UniqueEmailValidator('inputEmail', true, 'Email address is currently in use'));
     $context |= $kEmailUpdate;
 }
 if (strlen($form->inputPassword) > 0) {
     $form->addValidator(new MatchValidator('inputPassword', 'inputPasswordVerify', true, 'Password must match'));
     $form->addValidator(new InputValidator('inputPassword', true, 4, null, 'Password must be at least 4 characters long'));
     $form->addValidator(new InversePatternValidator('inputPassword', true, '/\\s/', 'Password may not contain spaces'));
     $context |= $kPasswordUpdate;
 }
 if ($context > 0) {
     $form->validate();
     if ($form->isValid) {
         $user = Renegade::authorizedUser();
         if ($context & $kEmailUpdate) {
             $user['email'] = $form->inputEmail;
         }
         if ($context & $kPasswordUpdate) {
             $user['password'] = renegade_security_hash($form->inputPassword);
         }
         $db = Renegade::database();
         $db->put($user, $user['_id']);
         $response->ok = true;
     } else {
         $response->error = 'invalid';
         $response->reason = 'validators';
         $response->validators = array();
         foreach ($form->validators as $validator) {
             if ($validator->isValid == false) {