mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-20 21:58:09 +00:00
working on registration support
This commit is contained in:
parent
cdde19d609
commit
121691e900
8 changed files with 72 additions and 3 deletions
|
@ -76,6 +76,7 @@ class Poche
|
||||||
*/
|
*/
|
||||||
public function createNewUser($username, $password, $email = "")
|
public function createNewUser($username, $password, $email = "")
|
||||||
{
|
{
|
||||||
|
Tools::logm('Trying to create a new user...');
|
||||||
if (!empty($username) && !empty($password)){
|
if (!empty($username) && !empty($password)){
|
||||||
$newUsername = filter_var($username, FILTER_SANITIZE_STRING);
|
$newUsername = filter_var($username, FILTER_SANITIZE_STRING);
|
||||||
$email = filter_var($email, FILTER_SANITIZE_STRING);
|
$email = filter_var($email, FILTER_SANITIZE_STRING);
|
||||||
|
@ -96,6 +97,9 @@ class Poche
|
||||||
Tools::redirect();
|
Tools::redirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Tools::logm('Password or username were empty');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,6 +67,12 @@ class Routing
|
||||||
$this->wallabag->action($this->action, $this->url, $this->id);
|
$this->wallabag->action($this->action, $this->url, $this->id);
|
||||||
$tplFile = Tools::getTplFile($this->view);
|
$tplFile = Tools::getTplFile($this->view);
|
||||||
$tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id));
|
$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'])) {
|
} elseif(isset($_SERVER['PHP_AUTH_USER'])) {
|
||||||
if($this->wallabag->store->userExists($_SERVER['PHP_AUTH_USER'])) {
|
if($this->wallabag->store->userExists($_SERVER['PHP_AUTH_USER'])) {
|
||||||
$this->wallabag->login($this->referer);
|
$this->wallabag->login($this->referer);
|
||||||
|
@ -104,7 +110,9 @@ class Routing
|
||||||
$tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
|
$tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
|
||||||
$limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 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);
|
$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
|
//allowed ONLY to logged in user
|
||||||
if (\Session::isLogged() === true)
|
if (\Session::isLogged() === true)
|
||||||
|
|
|
@ -117,7 +117,7 @@ final class Tools
|
||||||
{
|
{
|
||||||
$views = array(
|
$views = array(
|
||||||
'install', 'import', 'export', 'config', 'tags',
|
'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');
|
return (in_array($view, $views) ? $view . '.twig' : 'home.twig');
|
||||||
|
|
|
@ -31,7 +31,9 @@
|
||||||
@define ('SSL_PORT', 443);
|
@define ('SSL_PORT', 443);
|
||||||
|
|
||||||
@define ('MODE_DEMO', FALSE);
|
@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.
|
//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);
|
@define ('ERROR_REPORTING', E_ALL & ~E_NOTICE);
|
||||||
|
|
|
@ -31,4 +31,9 @@
|
||||||
<input type="hidden" name="token" value="{{ token }}">
|
<input type="hidden" name="token" value="{{ token }}">
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if constant('ALLOW_REGISTER') == 1 %}
|
||||||
|
<div class="register">
|
||||||
|
<a href="?registerform">{% trans "Register" %}</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
25
themes/baggy/register.twig
Normal file
25
themes/baggy/register.twig
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{% extends "layout-login.twig" %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h2>{% trans 'Add user' %}</h2>
|
||||||
|
<form method="post" action="?register">
|
||||||
|
<fieldset class="w500p">
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="newusername">{% trans 'Login' %}</label>
|
||||||
|
<input class="col" type="text" id="newusername" name="newusername" placeholder="{% trans 'Login' %}" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="password4newuser">{% trans "Password" %}</label>
|
||||||
|
<input class="col" type="password" id="password4newuser" name="password4newuser" placeholder="{% trans 'Password' %}" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="newuseremail">{% trans 'Email' %}</label>
|
||||||
|
<input class="col" type="email" id="newuseremail" name="newuseremail" placeholder="{% trans 'Email' %}">
|
||||||
|
</div>
|
||||||
|
<div class="row mts txtcenter">
|
||||||
|
<button type="submit">{% trans "Register" %}</button>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -31,4 +31,9 @@
|
||||||
<input type="hidden" name="token" value="{{ token }}">
|
<input type="hidden" name="token" value="{{ token }}">
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if constant('ALLOW_REGISTER') == 1 %}
|
||||||
|
<div class="registerform">
|
||||||
|
<a href="?register">{% trans "Register" %}</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
20
themes/default/register.twig
Normal file
20
themes/default/register.twig
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<h2>{% trans 'Add user' %}</h2>
|
||||||
|
<form method="post" action="?newuser">
|
||||||
|
<fieldset class="w500p">
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="newusername">{% trans 'Login' %}</label>
|
||||||
|
<input class="col" type="text" id="newusername" name="newusername" placeholder="{% trans 'Login' %}" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="password4newuser">{% trans "Password" %}</label>
|
||||||
|
<input class="col" type="password" id="password4newuser" name="password4newuser" placeholder="{% trans 'Password' %}" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="newuseremail">{% trans 'Email' %}</label>
|
||||||
|
<input class="col" type="email" id="newuseremail" name="newuseremail" placeholder="{% trans 'Email' %}">
|
||||||
|
</div>
|
||||||
|
<div class="row mts txtcenter">
|
||||||
|
<button type="submit">{% trans "Register" %}</button>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
Loading…
Reference in a new issue