Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions app/Controllers/authController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function loginAction() {
public function formLoginAction() {
invalidateHttpCache();

Minz_View::prependTitle(_t('gen.auth.login') . ' · ');
Minz_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js')));

$conf = Minz_Configuration::get('system');
Expand All @@ -122,7 +123,10 @@ public function formLoginAction() {

$conf = get_user_configuration($username);
if ($conf == null) {
Minz_Error::error(403, array(_t('feedback.auth.login.invalid')), false);
Minz_Request::bad(
_t('feedback.auth.login.invalid'),
array('c' => 'auth', 'a' => 'login')
);
return;
}

Expand Down Expand Up @@ -151,7 +155,10 @@ public function formLoginAction() {
' user=' . $username .
', nonce=' . $nonce .
', c=' . $challenge);
Minz_Error::error(403, array(_t('feedback.auth.login.invalid')), false);
Minz_Request::bad(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new code returns 200, and not 403 anymore, right? It could be good to reintroduce the 403 at some point.
Indeed, error codes are used by other systems (such as fail2ban) e.g. to detect attacts

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be exact it returns a 302. I think there's work to do on how we handle responses, and errors in particular but I didn't want to make this PR too complicated. Here I wanted to keep the users on the same URL (?c=auth&a=login) for consistency and because there's a small condition that would be skipped otherwise (nothing dramatic).

It wouldn't be too complicated to rework this part, though I'm not sure how important it is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_t('feedback.auth.login.invalid'),
array('c' => 'auth', 'a' => 'login')
);
}
} elseif (FreshRSS_Context::$system_conf->unsafe_autologin_enabled) {
$username = Minz_Request::param('u', '');
Expand Down Expand Up @@ -182,7 +189,10 @@ public function formLoginAction() {
array('c' => 'index', 'a' => 'index'));
} else {
Minz_Log::warning('Unsafe password mismatch for user ' . $username);
Minz_Error::error(403, array(_t('feedback.auth.login.invalid')), false);
Minz_Request::bad(
_t('feedback.auth.login.invalid'),
array('c' => 'auth', 'a' => 'login')
);
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions app/Controllers/userController.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,27 @@ public function createAction() {
$email = Minz_Request::param('new_user_email', '');
$passwordPlain = Minz_Request::param('new_user_passwordPlain', '', true);

if (!self::checkUsername($new_user_name)) {
Minz_Request::bad(
_t('user.username.invalid'),
array('c' => 'auth', 'a' => 'register')
);
}

if (FreshRSS_UserDAO::exists($new_user_name)) {
Minz_Request::bad(
_t('user.username.taken', $new_user_name),
array('c' => 'auth', 'a' => 'register')
);
}

if (!FreshRSS_password_Util::check($passwordPlain)) {
Minz_Request::bad(
_t('user.password.invalid'),
array('c' => 'auth', 'a' => 'register')
);
}

$tos_enabled = file_exists(join_path(DATA_PATH, 'tos.html'));
$accept_tos = Minz_Request::param('accept_tos', false);

Expand Down
13 changes: 13 additions & 0 deletions app/Utils/passwordUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,17 @@ public static function hash($passwordPlain) {

return $passwordHash == '' ? '' : $passwordHash;
}

/**
* Verify the given password is valid.
*
* A valid password is a string of at least 7 characters.
*
* @param string $password
*
* @return boolean True if the password is valid, false otherwise
*/
public static function check($password) {
return strlen($password) >= 7;
}
}
2 changes: 1 addition & 1 deletion app/i18n/cz/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Reset přihlášení',
'username' => array(
'admin' => 'Název administrátorského účtu',
'format' => '<small>maximálně 16 alfanumerických znaků</small>',
'format' => '<small>Maximálně 16 alfanumerických znaků</small>',
'_' => 'Uživatel',
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/cz/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Welcome %s,', // TODO - Translation
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'You must accept the Terms of Service to be able to register.', // TODO - Translation
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
Comment thread
Frenzie marked this conversation as resolved.
Resolved
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
2 changes: 1 addition & 1 deletion app/i18n/de/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Zurücksetzen der Authentifizierung',
'username' => array(
'admin' => 'Administrator-Nutzername',
'format' => '<small>maximal 16 alphanumerische Zeichen</small>',
'format' => '<small>Maximal 16 alphanumerische Zeichen</small>',
'_' => 'Nutzername',
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/de/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Willkommen, %s,',
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'Sie müssen die Nutzungsbedingungen akzeptieren um sich zu registrieren.',
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
2 changes: 1 addition & 1 deletion app/i18n/en/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Authentication reset',
'username' => array(
'admin' => 'Administrator username',
'format' => '<small>maximum 16 alphanumeric characters</small>',
'format' => '<small>Maximum 16 alphanumeric characters</small>',
'_' => 'Username',
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/en/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Welcome %s,',
),
),
'password' => array(
'invalid' => 'The password is invalid.',
),
'tos' => array(
'feedback' => array(
'invalid' => 'You must accept the Terms of Service to be able to register.',
),
),
'username' => array(
'invalid' => 'The username is invalid.',
'taken' => 'The username %s is taken.',
),
);
2 changes: 1 addition & 1 deletion app/i18n/es/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Reinicar identificación',
'username' => array(
'admin' => 'Nombre de usuario del Administrador',
'format' => '<small>máximo 16 caracteres alfanuméricos</small>',
'format' => '<small>Máximo 16 caracteres alfanuméricos</small>',
'_' => 'Nombre de usuario',
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/es/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Welcome %s,', // TODO - Translation
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'You must accept the Terms of Service to be able to register.', // TODO - Translation
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
7 changes: 7 additions & 0 deletions app/i18n/fr/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Bienvenue %s,',
),
),
'password' => array(
'invalid' => 'Le mot de passe est invalide.',
),
'tos' => array(
'feedback' => array(
'invalid' => 'Vous devez accepter les conditions générales d’utilisation pour pouvoir vous inscrire.',
),
),
'username' => array(
'invalid' => 'Le nom d’utilisateur est invalide.',
'taken' => 'Le nom d’utilisateur %s est pris.',
),
);
2 changes: 1 addition & 1 deletion app/i18n/he/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'איפוס אימות',
'username' => array(
'admin' => 'שם משתמש של המנהל',
'format' => '<small>maximum 16 alphanumeric characters</small>', // TODO - Translation
'format' => '<small>Maximum 16 alphanumeric characters</small>', // TODO - Translation
'_' => 'שם משתמש',
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/he/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Welcome %s,', // TODO - Translation
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'You must accept the Terms of Service to be able to register.', // TODO - Translation
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
2 changes: 1 addition & 1 deletion app/i18n/it/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Reset autenticazione',
'username' => array(
'admin' => 'Username amministratore',
'format' => '<small>massimo 16 caratteri alfanumerici</small>',
'format' => '<small>Massimo 16 caratteri alfanumerici</small>',
'_' => 'Username', // TODO - Translation
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/it/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Welcome %s,', // TODO - Translation
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'You must accept the Terms of Service to be able to register.', // TODO - Translation
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
7 changes: 7 additions & 0 deletions app/i18n/kr/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Welcome %s,', // TODO - Translation
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'You must accept the Terms of Service to be able to register.', // TODO - Translation
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
2 changes: 1 addition & 1 deletion app/i18n/nl/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Authenticatie reset',
'username' => array(
'admin' => 'Beheerdersgebruikersnaam',
'format' => '<small>maximaal 16 alfanumerieke tekens</small>',
'format' => '<small>Maximaal 16 alfanumerieke tekens</small>',
'_' => 'Gebruikersnaam',
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/nl/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Welkom %s,',
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'De gebruiksvoorwaarden moeten worden geaccepteerd om te kunnen registeren.',
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
2 changes: 1 addition & 1 deletion app/i18n/oc/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Reïnicializacion de l’autentificacion',
'username' => array(
'admin' => 'Nom d’utilizaire administrator',
'format' => '<small>16 caractèrs alfanumerics maximum)</small>',
'format' => '<small>16 caractèrs alfanumerics maximum</small>',
'_' => 'Nom d’utilizaire',
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/oc/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'La benvenguda %s,',
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'Vos cal acceptar las condicions d’utilizacion per poder vos inscriure.',
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
2 changes: 1 addition & 1 deletion app/i18n/pt-br/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Reset autenticação',
'username' => array(
'admin' => 'Usuário administrador',
'format' => '<small>máximo 16 caracteres alphanumericos</small>',
'format' => '<small>Máximo 16 caracteres alphanumericos</small>',
'_' => 'Usuário',
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/pt-br/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Welcome %s,', // TODO - Translation
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'You must accept the Terms of Service to be able to register.', // TODO - Translation
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
2 changes: 1 addition & 1 deletion app/i18n/ru/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Authentication reset', // TODO - Translation
'username' => array(
'admin' => 'Administrator username', // TODO - Translation
'format' => '<small>maximum 16 alphanumeric characters</small>', // TODO - Translation
'format' => '<small>Maximum 16 alphanumeric characters</small>', // TODO - Translation
'_' => 'Username', // TODO - Translation
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/i18n/ru/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
'welcome' => 'Welcome %s,', // TODO - Translation
),
),
'password' => array(
'invalid' => 'The password is invalid.', // TODO - Translation
),
'tos' => array(
'feedback' => array(
'invalid' => 'You must accept the Terms of Service to be able to register.', // TODO - Translation
),
),
'username' => array(
'invalid' => 'The username is invalid.', // TODO - Translation
'taken' => 'The username %s is taken.', // TODO - Translation
),
);
2 changes: 1 addition & 1 deletion app/i18n/sk/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'reset' => 'Reset prihlásenia',
'username' => array(
'admin' => 'Administrátorské používateľské meno',
'format' => '<small>maximálne 16 alfanumerických znakov</small>',
'format' => '<small>Maximálne 16 alfanumerických znakov</small>',
'_' => 'Používateľské meno',
),
),
Expand Down
Loading