aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xinc/poche/Poche.class.php4
-rwxr-xr-xinc/poche/Routing.class.php10
-rwxr-xr-xinc/poche/Tools.class.php2
-rwxr-xr-xinc/poche/config.inc.default.php4
-rw-r--r--themes/baggy/login.twig5
-rw-r--r--themes/baggy/register.twig25
-rw-r--r--themes/default/login.twig5
-rw-r--r--themes/default/register.twig20
8 files changed, 72 insertions, 3 deletions
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
76 */ 76 */
77 public function createNewUser($username, $password, $email = "") 77 public function createNewUser($username, $password, $email = "")
78 { 78 {
79 Tools::logm('Trying to create a new user...');
79 if (!empty($username) && !empty($password)){ 80 if (!empty($username) && !empty($password)){
80 $newUsername = filter_var($username, FILTER_SANITIZE_STRING); 81 $newUsername = filter_var($username, FILTER_SANITIZE_STRING);
81 $email = filter_var($email, FILTER_SANITIZE_STRING); 82 $email = filter_var($email, FILTER_SANITIZE_STRING);
@@ -96,6 +97,9 @@ class Poche
96 Tools::redirect(); 97 Tools::redirect();
97 } 98 }
98 } 99 }
100 else {
101 Tools::logm('Password or username were empty');
102 }
99 } 103 }
100 104
101 /** 105 /**
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
67 $this->wallabag->action($this->action, $this->url, $this->id); 67 $this->wallabag->action($this->action, $this->url, $this->id);
68 $tplFile = Tools::getTplFile($this->view); 68 $tplFile = Tools::getTplFile($this->view);
69 $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id)); 69 $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id));
70 } elseif(ALLOW_REGISTER && isset($_GET['registerform'])) {
71 Tools::logm('register');
72 $tplFile = Tools::getTplFile('register');
73 } elseif (ALLOW_REGISTER && isset($_GET['register'])){
74 $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser']);
75 Tools::redirect();
70 } elseif(isset($_SERVER['PHP_AUTH_USER'])) { 76 } elseif(isset($_SERVER['PHP_AUTH_USER'])) {
71 if($this->wallabag->store->userExists($_SERVER['PHP_AUTH_USER'])) { 77 if($this->wallabag->store->userExists($_SERVER['PHP_AUTH_USER'])) {
72 $this->wallabag->login($this->referer); 78 $this->wallabag->login($this->referer);
@@ -104,7 +110,9 @@ class Routing
104 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); 110 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
105 $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0); 111 $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0);
106 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit); 112 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit);
107 } 113 } //elseif (ALLOW_REGISTER && isset($_GET['register'])) {
114 //$this->wallabag->register
115 //}
108 116
109 //allowed ONLY to logged in user 117 //allowed ONLY to logged in user
110 if (\Session::isLogged() === true) 118 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
117 { 117 {
118 $views = array( 118 $views = array(
119 'install', 'import', 'export', 'config', 'tags', 119 'install', 'import', 'export', 'config', 'tags',
120 'edit-tags', 'view', 'login', 'error', 'about' 120 'edit-tags', 'view', 'login', 'error', 'about', 'register'
121 ); 121 );
122 122
123 return (in_array($view, $views) ? $view . '.twig' : 'home.twig'); 123 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 @@
31@define ('SSL_PORT', 443); 31@define ('SSL_PORT', 443);
32 32
33@define ('MODE_DEMO', FALSE); 33@define ('MODE_DEMO', FALSE);
34@define ('DEBUG_POCHE', FALSE); 34@define ('DEBUG_POCHE', TRUE);
35
36@define ('ALLOW_REGISTER', TRUE);
35 37
36//default level of error reporting in application. Developers should override it in their config.inc.php: set to E_ALL. 38//default level of error reporting in application. Developers should override it in their config.inc.php: set to E_ALL.
37@define ('ERROR_REPORTING', E_ALL & ~E_NOTICE); 39@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 @@
31 <input type="hidden" name="token" value="{{ token }}"> 31 <input type="hidden" name="token" value="{{ token }}">
32 </form> 32 </form>
33 {% endif %} 33 {% endif %}
34 {% if constant('ALLOW_REGISTER') == 1 %}
35 <div class="register">
36 <a href="?registerform">{% trans "Register" %}</a>
37 </div>
38 {% endif %}
34{% endblock %} 39{% 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 @@
1{% extends "layout-login.twig" %}
2{% block content %}
3
4<h2>{% trans 'Add user' %}</h2>
5 <form method="post" action="?register">
6 <fieldset class="w500p">
7 <div class="row">
8 <label class="col w150p" for="newusername">{% trans 'Login' %}</label>
9 <input class="col" type="text" id="newusername" name="newusername" placeholder="{% trans 'Login' %}" required>
10 </div>
11 <div class="row">
12 <label class="col w150p" for="password4newuser">{% trans "Password" %}</label>
13 <input class="col" type="password" id="password4newuser" name="password4newuser" placeholder="{% trans 'Password' %}" required>
14 </div>
15 <div class="row">
16 <label class="col w150p" for="newuseremail">{% trans 'Email' %}</label>
17 <input class="col" type="email" id="newuseremail" name="newuseremail" placeholder="{% trans 'Email' %}">
18 </div>
19 <div class="row mts txtcenter">
20 <button type="submit">{% trans "Register" %}</button>
21 </div>
22 </fieldset>
23 </form>
24
25{% 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 @@
31 <input type="hidden" name="token" value="{{ token }}"> 31 <input type="hidden" name="token" value="{{ token }}">
32 </form> 32 </form>
33 {% endif %} 33 {% endif %}
34 {% if constant('ALLOW_REGISTER') == 1 %}
35 <div class="registerform">
36 <a href="?register">{% trans "Register" %}</a>
37 </div>
38 {% endif %}
34{% endblock %} 39{% 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 @@
1<h2>{% trans 'Add user' %}</h2>
2 <form method="post" action="?newuser">
3 <fieldset class="w500p">
4 <div class="row">
5 <label class="col w150p" for="newusername">{% trans 'Login' %}</label>
6 <input class="col" type="text" id="newusername" name="newusername" placeholder="{% trans 'Login' %}" required>
7 </div>
8 <div class="row">
9 <label class="col w150p" for="password4newuser">{% trans "Password" %}</label>
10 <input class="col" type="password" id="password4newuser" name="password4newuser" placeholder="{% trans 'Password' %}" required>
11 </div>
12 <div class="row">
13 <label class="col w150p" for="newuseremail">{% trans 'Email' %}</label>
14 <input class="col" type="email" id="newuseremail" name="newuseremail" placeholder="{% trans 'Email' %}">
15 </div>
16 <div class="row mts txtcenter">
17 <button type="submit">{% trans "Register" %}</button>
18 </div>
19 </fieldset>
20 </form> \ No newline at end of file