Implement DB query

This commit is contained in:
Pellaeon Lin 2014-08-29 16:59:12 +00:00
parent 4b9a97cb08
commit b1b06947bf
1 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,7 @@
namespace OCA\Registration\Db; namespace OCA\Registration\Db;
use \OCP\IDb; use \OCP\IDb;
use \OCP\Util;
class PendingRegist { class PendingRegist {
@ -11,7 +12,16 @@ class PendingRegist {
$this->db = $db; $this->db = $db;
} }
public function find($id) { public function savePendingRegistration($email) {
$query = $this->db->prepareQuery( 'INSERT INTO `*PREFIX*registration`'
.' ( `email`, `token`, `requested` ) VALUES( ?, ?, ? )' );
$token = hash('sha256', generateRandomBytes(30).OC_Config::getValue('passwordsalt', ''));
$query->execute(array( $email, $token, time() ));
return $token;
}
public function find($email) {
$query = $this->db->prepareQuery('SELECT `email` FROM `*PREFIX*registration` WHERE `email` = ? ');
return $query->execute(array($email))->fetchAll();
} }
} }