From 37f06799589d9bb92ecfa6368197daf187251ab4 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 21 Jul 2015 16:03:46 +0200 Subject: First draft for registration form See https://github.com/FreshRSS/FreshRSS/issues/679 --- app/views/auth/register.phtml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 app/views/auth/register.phtml (limited to 'app/views/auth/register.phtml') diff --git a/app/views/auth/register.phtml b/app/views/auth/register.phtml new file mode 100644 index 000000000..f67ecc4d9 --- /dev/null +++ b/app/views/auth/register.phtml @@ -0,0 +1,31 @@ +
+

+ +
+
+ + +
+ +
+ +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+
+ +

+
-- cgit v1.2.3 From 9fca5c70f33291cacc04e7bdfa01a12c6df3f97c Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 22 Jul 2015 12:20:00 +0200 Subject: Add some comments --- app/Controllers/userController.php | 19 +++++++++++++++++++ app/views/auth/register.phtml | 7 +++++++ 2 files changed, 26 insertions(+) (limited to 'app/views/auth/register.phtml') diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 1c7745753..c198d1328 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -103,6 +103,17 @@ class FreshRSS_user_Controller extends Minz_ActionController { $this->view->size_user = $entryDAO->size(); } + /** + * This action creates a new user. + * + * Request parameters are: + * - new_user_language + * - new_user_name + * - new_user_passwordPlain + * - new_user_email + * + * @todo clean up this method. Idea: write a method to init a user with basic information. + */ public function createAction() { if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) { $db = FreshRSS_Context::$system_conf->db; @@ -178,6 +189,14 @@ class FreshRSS_user_Controller extends Minz_ActionController { Minz_Request::forward(array('c' => 'user', 'a' => 'manage'), true); } + /** + * This action delete an existing user. + * + * Request parameter is: + * - username + * + * @todo clean up this method. Idea: create a User->clean() method. + */ public function deleteAction() { if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) { $db = FreshRSS_Context::$system_conf->db; diff --git a/app/views/auth/register.phtml b/app/views/auth/register.phtml index f67ecc4d9..31ab89d26 100644 --- a/app/views/auth/register.phtml +++ b/app/views/auth/register.phtml @@ -1,3 +1,10 @@ +

-- cgit v1.2.3 From 02c3546440f961018adc1e2c8e97c16f2aca18fc Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 22 Jul 2015 13:52:03 +0200 Subject: Registration action is handled and create a user See https://github.com/FreshRSS/FreshRSS/issues/679 --- app/Controllers/userController.php | 20 +++++++++++++++++--- app/views/auth/register.phtml | 7 +++++++ lib/lib_rss.php | 16 ++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) (limited to 'app/views/auth/register.phtml') diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index c198d1328..46f4f434d 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -12,9 +12,14 @@ class FreshRSS_user_Controller extends Minz_ActionController { * This action is called before every other action in that class. It is * the common boiler plate for every action. It is triggered by the * underlying framework. + * + * @todo clean up the access condition. */ public function firstAction() { - if (!FreshRSS_Auth::hasAccess()) { + if (!FreshRSS_Auth::hasAccess() && !( + Minz_Request::actionName() === 'create' && + !max_registrations_reached() + )) { Minz_Error::error(403); } } @@ -111,11 +116,16 @@ class FreshRSS_user_Controller extends Minz_ActionController { * - new_user_name * - new_user_passwordPlain * - new_user_email + * - r (i.e. a redirection url, optional) * * @todo clean up this method. Idea: write a method to init a user with basic information. + * @todo handle r redirection in Minz_Request::forward directly? */ public function createAction() { - if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) { + if (Minz_Request::isPost() && ( + FreshRSS_Auth::hasAccess('admin') || + !max_registrations_reached() + )) { $db = FreshRSS_Context::$system_conf->db; require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); @@ -186,7 +196,11 @@ class FreshRSS_user_Controller extends Minz_ActionController { Minz_Session::_param('notification', $notif); } - Minz_Request::forward(array('c' => 'user', 'a' => 'manage'), true); + $redirect_url = urldecode(Minz_Request::param('r', false, true)); + if (!$redirect_url) { + $redirect_url = array('c' => 'user', 'a' => 'manage'); + } + Minz_Request::forward($redirect_url, true); } /** diff --git a/app/views/auth/register.phtml b/app/views/auth/register.phtml index 31ab89d26..96c91f411 100644 --- a/app/views/auth/register.phtml +++ b/app/views/auth/register.phtml @@ -29,6 +29,13 @@
+ 'index', 'a' => 'index'), + 'php', true + )); + ?> +
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 0118e0f46..c99e2c7e8 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -266,6 +266,22 @@ function listUsers() { } +/** + * Return if the maximum number of registrations has been reached. + * + * Note a max_regstrations of 0 means there is no limit. + * + * @return true if number of users >= max registrations, false else. + */ +function max_registrations_reached() { + $system_conf = Minz_Configuration::get('system'); + $limit_registrations = $system_conf->limits['max_registrations']; + $number_accounts = count(listUsers()); + + return $limit_registrations > 0 && $number_accounts >= $limit_registrations; +} + + /** * Register and return the configuration for a given user. * -- cgit v1.2.3 From de2e221aca0639c45cfe30f049ec71a493b17a5c Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 22 Jul 2015 22:04:33 +0200 Subject: Fix translations See https://github.com/FreshRSS/FreshRSS/issues/679 --- app/i18n/cz/admin.php | 7 +++++++ app/i18n/cz/conf.php | 4 ++++ app/i18n/cz/gen.php | 5 +++++ app/i18n/de/admin.php | 7 +++++++ app/i18n/de/conf.php | 4 ++++ app/i18n/de/gen.php | 5 +++++ app/i18n/en/admin.php | 7 +++++++ app/i18n/en/conf.php | 4 ++++ app/i18n/en/gen.php | 5 +++++ app/i18n/fr/admin.php | 7 +++++++ app/i18n/fr/conf.php | 4 ++++ app/i18n/fr/gen.php | 5 +++++ app/views/auth/formLogin.phtml | 2 +- app/views/auth/personaLogin.phtml | 2 +- app/views/auth/register.phtml | 4 +--- app/views/user/manage.phtml | 5 ++++- 16 files changed, 71 insertions(+), 6 deletions(-) (limited to 'app/views/auth/register.phtml') diff --git a/app/i18n/cz/admin.php b/app/i18n/cz/admin.php index b9ef707cf..bfa67573e 100644 --- a/app/i18n/cz/admin.php +++ b/app/i18n/cz/admin.php @@ -160,8 +160,15 @@ return array( 'create' => 'Vytvořit nového uživatele', 'email_persona' => 'Email pro přihlášení
(pro Mozilla Persona)', 'language' => 'Jazyk', + 'number' => 'There is %d account created yet', // TODO: translate + 'numbers' => 'There are %d accounts created yet', // TODO: translate 'password_form' => 'Heslo
(pro přihlášení webovým formulářem)', 'password_format' => 'Alespoň 7 znaků', + 'registration' => array( + 'allow' => 'Allow account creation', // TODO: translate + 'help' => '0 means that there is no account limit', // TODO: translate + 'number' => 'Max number of accounts', // TODO: translate + ), 'title' => 'Správa uživatelů', 'user_list' => 'Seznam uživatelů', 'username' => 'Přihlašovací jméno', diff --git a/app/i18n/cz/conf.php b/app/i18n/cz/conf.php index 9518df66d..859eeac89 100644 --- a/app/i18n/cz/conf.php +++ b/app/i18n/cz/conf.php @@ -72,6 +72,10 @@ return array( ), 'profile' => array( '_' => 'Správa profilu', + 'delete' => array( + '_' => 'Account deletion', // TODO: translate + 'warn' => 'Your account and all the related data will be deleted.', // TODO: translate + ), 'email_persona' => 'Email pro přihlášení
(pro Mozilla Persona)', 'password_api' => 'Password API
(tzn. pro mobilní aplikace)', 'password_form' => 'Heslo
(pro přihlášení webovým formulářem)', diff --git a/app/i18n/cz/gen.php b/app/i18n/cz/gen.php index 7c333a9c8..13e0db261 100644 --- a/app/i18n/cz/gen.php +++ b/app/i18n/cz/gen.php @@ -21,12 +21,17 @@ return array( 'truncate' => 'Smazat všechny články', ), 'auth' => array( + 'email' => 'Email', 'keep_logged_in' => 'Zapamatovat přihlášení (1 měsíc)', 'login' => 'Login', 'login_persona' => 'Přihlášení pomocí Persona', 'login_persona_problem' => 'Problém s připojením k Persona?', 'logout' => 'Odhlášení', 'password' => 'Heslo', + 'registration' => array( + '_' => 'New account', // TODO: translate + 'ask' => 'Create an account?', // TODO: translate + ), 'reset' => 'Reset přihlášení', 'username' => 'Uživatel', 'username_admin' => 'Název administrátorského účtu', diff --git a/app/i18n/de/admin.php b/app/i18n/de/admin.php index c0cbf6787..667f7af8d 100644 --- a/app/i18n/de/admin.php +++ b/app/i18n/de/admin.php @@ -160,8 +160,15 @@ return array( 'create' => 'Neuen Benutzer erstellen', 'email_persona' => 'Anmelde-E-Mail-Adresse
(für Mozilla Persona)', 'language' => 'Sprache', + 'number' => 'There is %d account created yet', // TODO: translate + 'numbers' => 'There are %d accounts created yet', // TODO: translate 'password_form' => 'Passwort
(für die Anmeldemethode per Webformular)', 'password_format' => 'mindestens 7 Zeichen', + 'registration' => array( + 'allow' => 'Allow account creation', // TODO: translate + 'help' => '0 means that there is no account limit', // TODO: translate + 'number' => 'Max number of accounts', // TODO: translate + ), 'title' => 'Benutzer verwalten', 'user_list' => 'Liste der Benutzer', 'username' => 'Nutzername', diff --git a/app/i18n/de/conf.php b/app/i18n/de/conf.php index 4a0a77ddd..5313ec3fd 100644 --- a/app/i18n/de/conf.php +++ b/app/i18n/de/conf.php @@ -72,6 +72,10 @@ return array( ), 'profile' => array( '_' => 'Profil-Verwaltung', + 'delete' => array( + '_' => 'Account deletion', // TODO: translate + 'warn' => 'Your account and all the related data will be deleted.', // TODO: translate + ), 'email_persona' => 'Anmelde-E-Mail-Adresse
(für Mozilla Persona)', 'password_api' => 'Passwort-API
(z. B. für mobile Anwendungen)', 'password_form' => 'Passwort
(für die Anmeldemethode per Webformular)', diff --git a/app/i18n/de/gen.php b/app/i18n/de/gen.php index f24a52c2e..9682a4a21 100644 --- a/app/i18n/de/gen.php +++ b/app/i18n/de/gen.php @@ -21,12 +21,17 @@ return array( 'truncate' => 'Alle Artikel löschen', ), 'auth' => array( + 'email' => 'E-Mail-Adresse', 'keep_logged_in' => 'Eingeloggt bleiben (1 Monat)', 'login' => 'Anmelden', 'login_persona' => 'Anmelden mit Persona', 'login_persona_problem' => 'Verbindungsproblem mit Persona?', 'logout' => 'Abmelden', 'password' => 'Passwort', + 'registration' => array( + '_' => 'New account', // TODO: translate + 'ask' => 'Create an account?', // TODO: translate + ), 'reset' => 'Zurücksetzen der Authentifizierung', 'username' => 'Nutzername', 'username_admin' => 'Administrator-Nutzername', diff --git a/app/i18n/en/admin.php b/app/i18n/en/admin.php index 155384afd..aeea61631 100644 --- a/app/i18n/en/admin.php +++ b/app/i18n/en/admin.php @@ -160,8 +160,15 @@ return array( 'create' => 'Create new user', 'email_persona' => 'Login mail address
(for Mozilla Persona)', 'language' => 'Language', + 'number' => 'There is %d account created yet', + 'numbers' => 'There are %d accounts created yet', 'password_form' => 'Password
(for the Web-form login method)', 'password_format' => 'At least 7 characters', + 'registration' => array( + 'allow' => 'Allow account creation', + 'help' => '0 means that there is no account limit', + 'number' => 'Max number of accounts', + ), 'title' => 'Manage users', 'user_list' => 'List of users', 'username' => 'Username', diff --git a/app/i18n/en/conf.php b/app/i18n/en/conf.php index 42a06906d..69162932f 100644 --- a/app/i18n/en/conf.php +++ b/app/i18n/en/conf.php @@ -72,6 +72,10 @@ return array( ), 'profile' => array( '_' => 'Profile management', + 'delete' => array( + '_' => 'Account deletion', + 'warn' => 'Your account and all the related data will be deleted.', + ), 'email_persona' => 'Login email address
(for Mozilla Persona)', 'password_api' => 'Password API
(e.g., for mobile apps)', 'password_form' => 'Password
(for the Web-form login method)', diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index 6e47e0921..ac55a1a3b 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -21,12 +21,17 @@ return array( 'truncate' => 'Delete all articles', ), 'auth' => array( + 'email' => 'Email address', 'keep_logged_in' => 'Keep me logged in (1 month)', 'login' => 'Login', 'login_persona' => 'Login with Persona', 'login_persona_problem' => 'Connection problem with Persona?', 'logout' => 'Logout', 'password' => 'Password', + 'registration' => array( + '_' => 'New account', + 'ask' => 'Create an account?', + ), 'reset' => 'Authentication reset', 'username' => 'Username', 'username_admin' => 'Administrator username', diff --git a/app/i18n/fr/admin.php b/app/i18n/fr/admin.php index b740bd0d2..01e0cb3c7 100644 --- a/app/i18n/fr/admin.php +++ b/app/i18n/fr/admin.php @@ -160,8 +160,15 @@ return array( 'create' => 'Créer un nouvel utilisateur', 'email_persona' => 'Adresse courriel de connexion
(pour Mozilla Persona)', 'language' => 'Langue', + 'number' => '%d compte a déjà été créé', + 'numbers' => '%d comptes ont déjà été créés', 'password_form' => 'Mot de passe
(pour connexion par formulaire)', 'password_format' => '7 caractères minimum', + 'registration' => array( + 'allow' => 'Autoriser la création de comptes', + 'help' => 'Un chiffre de 0 signifie que l’on peut créer un nombre infini de comptes', + 'number' => 'Nombre max de comptes', + ), 'title' => 'Gestion des utilisateurs', 'user_list' => 'Liste des utilisateurs', 'username' => 'Nom d’utilisateur', diff --git a/app/i18n/fr/conf.php b/app/i18n/fr/conf.php index 87f9be290..6193b7a01 100644 --- a/app/i18n/fr/conf.php +++ b/app/i18n/fr/conf.php @@ -72,6 +72,10 @@ return array( ), 'profile' => array( '_' => 'Gestion du profil', + 'delete' => array( + '_' => 'Suppression du compte', + 'warn' => 'Le compte et toutes les données associées vont être supprimées.', + ), 'email_persona' => 'Adresse courriel de connexion
(pour Mozilla Persona)', 'password_api' => 'Mot de passe API
(ex. : pour applis mobiles)', 'password_form' => 'Mot de passe
(pour connexion par formulaire)', diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index c81e57bf7..3336b6a03 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -21,12 +21,17 @@ return array( 'truncate' => 'Supprimer tous les articles', ), 'auth' => array( + 'email' => 'Adresse courriel', 'keep_logged_in' => 'Rester connecté (1 mois)', 'login' => 'Connexion', 'login_persona' => 'Connexion avec Persona', 'login_persona_problem' => 'Problème de connexion à Persona ?', 'logout' => 'Déconnexion', 'password' => 'Mot de passe', + 'registration' => array( + '_' => 'Nouveau compte', + 'ask' => 'Créer un compte ?', + ), 'reset' => 'Réinitialisation de l’authentification', 'username' => 'Nom d’utilisateur', 'username_admin' => 'Nom d’utilisateur administrateur', diff --git a/app/views/auth/formLogin.phtml b/app/views/auth/formLogin.phtml index 3a6053065..b0083944f 100644 --- a/app/views/auth/formLogin.phtml +++ b/app/views/auth/formLogin.phtml @@ -2,7 +2,7 @@

- +
diff --git a/app/views/auth/personaLogin.phtml b/app/views/auth/personaLogin.phtml index 91349a67e..c6d738bf6 100644 --- a/app/views/auth/personaLogin.phtml +++ b/app/views/auth/personaLogin.phtml @@ -3,7 +3,7 @@

- +

diff --git a/app/views/auth/register.phtml b/app/views/auth/register.phtml index 96c91f411..ada654b15 100644 --- a/app/views/auth/register.phtml +++ b/app/views/auth/register.phtml @@ -1,12 +1,10 @@

-

+

diff --git a/app/views/user/manage.phtml b/app/views/user/manage.phtml index 61b296528..3d3bc3ddf 100644 --- a/app/views/user/manage.phtml +++ b/app/views/user/manage.phtml @@ -16,7 +16,10 @@
- + 1 ? 'admin.user.numbers' : 'admin.user.number', $number); + ?>
-- cgit v1.2.3 From 669c41114f60a5a31253bed766f52e1840e00599 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 22 Jul 2015 22:28:21 +0200 Subject: Show indications for username and password formats See https://github.com/FreshRSS/FreshRSS/issues/679 --- app/i18n/cz/gen.php | 12 +++++++++--- app/i18n/de/gen.php | 12 +++++++++--- app/i18n/en/gen.php | 12 +++++++++--- app/i18n/fr/gen.php | 12 +++++++++--- app/views/auth/register.phtml | 9 ++------- app/views/auth/reset.phtml | 2 +- 6 files changed, 39 insertions(+), 20 deletions(-) (limited to 'app/views/auth/register.phtml') diff --git a/app/i18n/cz/gen.php b/app/i18n/cz/gen.php index 13e0db261..a89bf6b49 100644 --- a/app/i18n/cz/gen.php +++ b/app/i18n/cz/gen.php @@ -27,14 +27,20 @@ return array( 'login_persona' => 'Přihlášení pomocí Persona', 'login_persona_problem' => 'Problém s připojením k Persona?', 'logout' => 'Odhlášení', - 'password' => 'Heslo', + 'password' => array( + '_' => 'Heslo', + 'format' => 'Alespoň 7 znaků', + ), 'registration' => array( '_' => 'New account', // TODO: translate 'ask' => 'Create an account?', // TODO: translate ), 'reset' => 'Reset přihlášení', - 'username' => 'Uživatel', - 'username_admin' => 'Název administrátorského účtu', + 'username' => array( + '_' => 'Uživatel', + 'admin' => 'Název administrátorského účtu', + 'format' => 'maximálně 16 alfanumerických znaků', + ), 'will_reset' => 'Přihlašovací systém bude vyresetován: místo sytému Persona bude použito přihlášení formulářem.', ), 'date' => array( diff --git a/app/i18n/de/gen.php b/app/i18n/de/gen.php index 9682a4a21..d6fcfe1e4 100644 --- a/app/i18n/de/gen.php +++ b/app/i18n/de/gen.php @@ -27,14 +27,20 @@ return array( 'login_persona' => 'Anmelden mit Persona', 'login_persona_problem' => 'Verbindungsproblem mit Persona?', 'logout' => 'Abmelden', - 'password' => 'Passwort', + 'password' => array( + '_' => 'Passwort', + 'format' => 'mindestens 7 Zeichen', + ), 'registration' => array( '_' => 'New account', // TODO: translate 'ask' => 'Create an account?', // TODO: translate ), 'reset' => 'Zurücksetzen der Authentifizierung', - 'username' => 'Nutzername', - 'username_admin' => 'Administrator-Nutzername', + 'username' => array( + '_' => 'Nutzername', + 'admin' => 'Administrator-Nutzername', + 'format' => 'maximal 16 alphanumerische Zeichen', + ), 'will_reset' => 'Authentifikationssystem wird zurückgesetzt: ein Formular wird anstelle von Persona benutzt.', ), 'date' => array( diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index ac55a1a3b..063322cbf 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -27,14 +27,20 @@ return array( 'login_persona' => 'Login with Persona', 'login_persona_problem' => 'Connection problem with Persona?', 'logout' => 'Logout', - 'password' => 'Password', + 'password' => array( + '_' => 'Password', + 'format' => 'At least 7 characters', + ), 'registration' => array( '_' => 'New account', 'ask' => 'Create an account?', ), 'reset' => 'Authentication reset', - 'username' => 'Username', - 'username_admin' => 'Administrator username', + 'username' => array( + '_' => 'Username', + 'admin' => 'Administrator username', + 'format' => 'maximum 16 alphanumeric characters', + ), 'will_reset' => 'Authentication system will be reset: a form will be used instead of Persona.', ), 'date' => array( diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index 3336b6a03..5abc7a27b 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -27,14 +27,20 @@ return array( 'login_persona' => 'Connexion avec Persona', 'login_persona_problem' => 'Problème de connexion à Persona ?', 'logout' => 'Déconnexion', - 'password' => 'Mot de passe', + 'password' => array( + '_' => 'Mot de passe', + 'format' => '7 caractères minimum', + ), 'registration' => array( '_' => 'Nouveau compte', 'ask' => 'Créer un compte ?', ), 'reset' => 'Réinitialisation de l’authentification', - 'username' => 'Nom d’utilisateur', - 'username_admin' => 'Nom d’utilisateur administrateur', + 'username' => array( + '_' => 'Nom d’utilisateur', + 'admin' => 'Nom d’utilisateur administrateur', + 'format' => '16 caractères alphanumériques maximum', + ), 'will_reset' => 'Le système d’authentification va être réinitialisé : un formulaire sera utilisé à la place de Persona.', ), 'date' => array( diff --git a/app/views/auth/register.phtml b/app/views/auth/register.phtml index ada654b15..306679601 100644 --- a/app/views/auth/register.phtml +++ b/app/views/auth/register.phtml @@ -1,19 +1,14 @@ -

- +
- +
diff --git a/app/views/auth/reset.phtml b/app/views/auth/reset.phtml index 6e9816ad3..9c820c7c8 100644 --- a/app/views/auth/reset.phtml +++ b/app/views/auth/reset.phtml @@ -16,7 +16,7 @@

- +
-- cgit v1.2.3