Exemple #1
0
 public function testSetAndValidatePassword()
 {
     // Create a dummy user record
     $user = new Dbi_Record(new Model_User(), array('userid' => '1000', 'username' => 'test', 'email' => '*****@*****.**', 'password' => 'password', 'auth' => 'Hash'));
     // Hash the password
     $event = new ModelEvent_HashPassword();
     $event->update($user);
     // Test authentication
     $auth = new Auth_Hash($user);
     $this->assertTrue($auth->validate('password'), 'Auth_Hash failed to validate password');
 }
Exemple #2
0
         $body = str_replace('$invoice_link', "{$_ENV['application']['base']}/hash/{$ah['hash']}", $body);
     }
     // @todo collect associated work-orders?
     $sql = 'SELECT DISTINCT workorder.id FROM workorder ';
     $sql .= ' JOIN workorder_item ON workorder.id = workorder_item.workorder_id ';
     $sql .= ' WHERE workorder_item.id IN ( ';
     $sql .= 'SELECT workorder_item_id FROM invoice_item WHERE invoice_item.invoice_id = %d ';
     $sql .= ') ';
     $sql .= ' ORDER BY 1 ';
     $res = $this->_d->fetchAll(sprintf($sql, $Invoice['id']));
     $id_list = array();
     // IDs
     $al_list = array();
     // Authorization Hash Links
     foreach ($res as $x) {
         $ah = Auth_Hash::make(new WorkOrder($x['id']));
         $id_list[] = sprintf('#%d', $x['id']);
         $al_list[] = sprintf('%s/hash/%s', $_ENV['application']['base'], $ah['hash']);
     }
     $body = str_replace('$workorder_id', implode(', ', $id_list), $body);
     $sep = "\n  ";
     // Default, use matched if one is found
     if (preg_match('/^(.+)\\$workorder_link/m', $body, $m)) {
         $sep = "\n{$m[1]}";
     }
     $body = str_replace('$workorder_link', implode($sep, $al_list), $body);
     $body = str_replace('$payment_link', "{$_ENV['application']['base']}/checkout/invoice/hash/{$Invoice->hash}", $body);
     $this->_s->EmailComposeMessage->body = $body;
 }
 $this->_s->ReturnGood = sprintf('/invoice/view?i=%d&sent=good', $Invoice['id']);
 $this->_s->ReturnFail = sprintf('/invoice/view?i=%d&sent=fail', $Invoice['id']);