Esempio n. 1
0
 public function make($email, $password, $remember = false)
 {
     $user = $this->sql("SELECT * FROM users WHERE email = ? AND is_ban = 0", [$email]);
     if ($user->getAffectedRows() == 1) {
         $user = $user->fetchRowAssoc();
         if (Hash::verify($password, $user['password'])) {
             $token = Common::generateToken();
             Session::getInstance()->getSession()->user_token = $token;
             $this->sql("UPDATE users SET access_token= ? WHERE id = ?", [$token, $user['id']]);
             return true;
         }
         return false;
     }
     return false;
 }
Esempio n. 2
0
 public function create($email, $password, $names)
 {
     $password = Hash::make($password);
     $last_id = $this->sql("INSERT INTO users (email, password, names) VALUES (?, ?, ?)", [$email, $password, $names])->getLastInsertId();
     Auth::byId($last_id);
 }