From 121691e90026dcfaaecef0a1db07d40cd43a9278 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 23 Jan 2015 16:34:56 +0100 Subject: [PATCH] working on registration support --- inc/poche/Poche.class.php | 4 ++++ inc/poche/Routing.class.php | 10 +++++++++- inc/poche/Tools.class.php | 2 +- inc/poche/config.inc.default.php | 4 +++- themes/baggy/login.twig | 5 +++++ themes/baggy/register.twig | 25 +++++++++++++++++++++++++ themes/default/login.twig | 5 +++++ themes/default/register.twig | 20 ++++++++++++++++++++ 8 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 themes/baggy/register.twig create mode 100644 themes/default/register.twig diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 81a18c86..36c8693c 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -76,6 +76,7 @@ class Poche */ public function createNewUser($username, $password, $email = "") { + Tools::logm('Trying to create a new user...'); if (!empty($username) && !empty($password)){ $newUsername = filter_var($username, FILTER_SANITIZE_STRING); $email = filter_var($email, FILTER_SANITIZE_STRING); @@ -96,6 +97,9 @@ class Poche Tools::redirect(); } } + else { + Tools::logm('Password or username were empty'); + } } /** diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php index be06a433..8d6abefd 100755 --- a/inc/poche/Routing.class.php +++ b/inc/poche/Routing.class.php @@ -67,6 +67,12 @@ class Routing $this->wallabag->action($this->action, $this->url, $this->id); $tplFile = Tools::getTplFile($this->view); $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id)); + } elseif(ALLOW_REGISTER && isset($_GET['registerform'])) { + Tools::logm('register'); + $tplFile = Tools::getTplFile('register'); + } elseif (ALLOW_REGISTER && isset($_GET['register'])){ + $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser']); + Tools::redirect(); } elseif(isset($_SERVER['PHP_AUTH_USER'])) { if($this->wallabag->store->userExists($_SERVER['PHP_AUTH_USER'])) { $this->wallabag->login($this->referer); @@ -104,7 +110,9 @@ class Routing $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0); $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit); - } + } //elseif (ALLOW_REGISTER && isset($_GET['register'])) { + //$this->wallabag->register + //} //allowed ONLY to logged in user if (\Session::isLogged() === true) diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 7ccfc069..d0b31d4f 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -117,7 +117,7 @@ final class Tools { $views = array( 'install', 'import', 'export', 'config', 'tags', - 'edit-tags', 'view', 'login', 'error', 'about' + 'edit-tags', 'view', 'login', 'error', 'about', 'register' ); return (in_array($view, $views) ? $view . '.twig' : 'home.twig'); diff --git a/inc/poche/config.inc.default.php b/inc/poche/config.inc.default.php index a159e713..3156b56c 100755 --- a/inc/poche/config.inc.default.php +++ b/inc/poche/config.inc.default.php @@ -31,7 +31,9 @@ @define ('SSL_PORT', 443); @define ('MODE_DEMO', FALSE); -@define ('DEBUG_POCHE', FALSE); +@define ('DEBUG_POCHE', TRUE); + +@define ('ALLOW_REGISTER', TRUE); //default level of error reporting in application. Developers should override it in their config.inc.php: set to E_ALL. @define ('ERROR_REPORTING', E_ALL & ~E_NOTICE); diff --git a/themes/baggy/login.twig b/themes/baggy/login.twig index 58290e9c..7906cc20 100644 --- a/themes/baggy/login.twig +++ b/themes/baggy/login.twig @@ -31,4 +31,9 @@ {% endif %} + {% if constant('ALLOW_REGISTER') == 1 %} +
+ {% trans "Register" %} +
+ {% endif %} {% endblock %} diff --git a/themes/baggy/register.twig b/themes/baggy/register.twig new file mode 100644 index 00000000..5744a481 --- /dev/null +++ b/themes/baggy/register.twig @@ -0,0 +1,25 @@ +{% extends "layout-login.twig" %} +{% block content %} + +

{% trans 'Add user' %}

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/themes/default/login.twig b/themes/default/login.twig index b9f8b497..d4f44019 100644 --- a/themes/default/login.twig +++ b/themes/default/login.twig @@ -31,4 +31,9 @@ {% endif %} + {% if constant('ALLOW_REGISTER') == 1 %} +
+ {% trans "Register" %} +
+ {% endif %} {% endblock %} diff --git a/themes/default/register.twig b/themes/default/register.twig new file mode 100644 index 00000000..755ae132 --- /dev/null +++ b/themes/default/register.twig @@ -0,0 +1,20 @@ +

{% trans 'Add user' %}

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
\ No newline at end of file -- 2.41.0