diff --git a/db/pendingregist.php b/db/pendingregist.php index 7e52a6e..34ab34f 100644 --- a/db/pendingregist.php +++ b/db/pendingregist.php @@ -2,6 +2,7 @@ namespace OCA\Registration\Db; use \OCP\IDb; +use \OCP\Util; class PendingRegist { @@ -11,7 +12,16 @@ class PendingRegist { $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(); } }