Implemented controller verifyToken

This commit is contained in:
Pellaeon Lin 2014-08-31 19:20:26 +02:00
parent d26481dbe8
commit e16e5df481
2 changed files with 25 additions and 1 deletions

View File

@ -82,11 +82,30 @@ class RegisterController extends Controller {
$res = new TemplateResponse('registration', 'email', array('link' => $link));
$msg = $res->render();
try {
$this->mail->send($email, 'ownCloud User', $l->t('Verify your ownCloud registration request'), $msg, $from, 'ownCloud');
$this->mail->send($email, 'ownCloud User', $this->l10n->t('Verify your ownCloud registration request'), $msg, $from, 'ownCloud');
} catch (Exception $e) {
\OC_Template::printErrorPage( 'A problem occurs during sending the e-mail please contact your administrator.');
return;
}
$this->askEmail('', true);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
*/
public function verifyToken($token) {
$email = $this->pendingreg->findByToken($token);
if ( \OCP\DB::isError($email) ) {
return new TemplateResponse('', 'error', array(
'errors' => array(array(
'error' => $this->l10n->t('Invalid verification URL. No registration request with this verification URL is found.'),
'hint' => ''
))
), 'error');
} elseif ( $email ) {
return new TemplateResponse('registration', 'form', array(), 'guest');
}
}
}

View File

@ -25,4 +25,9 @@ class PendingRegist {
return $query->execute(array($email))->fetchAll();
}
public function findByToken($token) {
$query = $this->db->prepareQuery('SELECT `email` FROM `*PREFIX*registration` WHERE `token` = ? ');
return $query->execute(array($token))->fetchOne();
}
}