Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow capitalized usernames if the regex agrees #2138

Closed
wants to merge 5 commits into from
Closed
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
12 changes: 6 additions & 6 deletions system/src/Grav/Common/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function load($username)
$locator = $grav['locator'];

// force lowercase of username
$username = strtolower($username);
$username = mb_strtolower($username);

$blueprints = new Blueprints;
$blueprint = $blueprints->get('user/account');
Expand Down Expand Up @@ -192,18 +192,18 @@ public function save()
if ($file) {
$username = $this->get('username');

if (!$file->filename()) {
$locator = Grav::instance()['locator'];
$file->filename($locator->findResource('account://') . DS . strtolower($username) . YAML_EXT);
}
$locator = Grav::instance()['locator'];
$file->filename($locator->findResource('account://') . DS . mb_strtolower($username) . YAML_EXT);

// if plain text password, hash it and remove plain text
if ($this->password) {
$this->hashed_password = Authentication::create($this->password);
unset($this->password);
}

unset($this->username);
if ($username == mb_strtolower($username)) {
unset($this->username);
}
$file->save($this->items);
$this->set('username', $username);
}
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ private static function generateNonceString($action, $previousTick = false)
$username = '';
if (isset(Grav::instance()['user'])) {
$user = Grav::instance()['user'];
$username = $user->username;
$username = mb_strtolower($user->username);
}

$token = session_id();
Expand Down