コード例 #1
0
ファイル: test.php プロジェクト: JustAHappyKid/bitcoin-chipin
function newUser($email, $username, $pw)
{
    require_once 'chipin/users.php';
    require_once 'chipin/passwords.php';
    # XXX: Note, we're not hashing passwords here...
    $uid = DB\insertOne('users', array('email' => $email, 'username' => $username, 'password' => Passwords\hash($pw)), true);
    return User::loadFromID($uid);
}
コード例 #2
0
 function testChangingPassword()
 {
     $userB4 = $this->loginAsNormalUser();
     assertFalse(Passwords\isValid('n00p@ss', $userB4->passwordEncrypted));
     $this->get('/account/change-password');
     $this->submitForm($this->getForm('change-password-form'), array('current-password' => 'abc123', 'password' => 'n00p@ss', 'confirm-password' => 'n00p@ss'));
     $userAfter = User::loadFromID($userB4->id);
     assertTrue(Passwords\isValid('n00p@ss', $userAfter->passwordEncrypted));
 }
コード例 #3
0
function getUserForCode($code)
{
    $rows = DB\simpleSelect('confirmation_codes', 'code = ?', array($code));
    $row = current($rows);
    if ($row == null) {
        throw new InvalidCode("No such confirmation code found ({$code})");
    }
    return User::loadFromID($row['user_id']);
}
コード例 #4
0
 function stepTwo()
 {
     $widget = $this->requireWidget();
     if ($this->isPostRequest()) {
         $user = $this->getActiveUser();
         if (empty($user)) {
             $uid = DB\insertOne('users', array('created_at' => new DateTime('now')), $returnId = true);
             $user = User::loadFromID($uid);
             $this->setActiveUser($user);
         }
         $widget->ownerID = $user->id;
         $widget->about = $_POST['about'];
         list($widget->width, $widget->height) = explode('x', $_POST['size']);
         $widget->color = $_POST['color'];
         $widget->countryCode = $this->getCountryCodeForIP();
         $widget->save();
         //$widget->updateProgress();
         $this->storeWidgetInSession($widget);
         return $this->redirect("/widget-wiz/step-three?w={$widget->id}");
     } else {
         return $this->renderStep('step-two.php', $widget);
     }
 }
コード例 #5
0
 function getOwner()
 {
     return User::loadFromID($this->ownerID);
 }