Allow usernames with capital letters

E: I think it should be possible to have capital letters in usernames. Kirby’s core should be changed accordingly.

Did I screw somethin up or why does my Panel forbid the use of capital letters in usernames?
Right now only small letters, numbers and dashes are allowed.

Where do you need to change sth in order to also allow capital letters in usernames?

I couldn’t find it on my own … so far.

Thanks

This actually happens within the core kirby files:

kirby/core/user.php

static public function create($data = array()) {
    // sanitize the given data for the new user
    $data = static::sanitize($data, 'insert');
    // ...
}
static public function sanitize($data, $mode = 'insert') {
    // all usernames must be lowercase
    $data['username'] = str::slug(a::get($data, 'username'));
    // return the cleaned up data
    return $data;
}

toolkit/lib/str.php

static public function slug($string, $separator = '-', $allowed = 'a-z0-9') {
    $string = trim($string);
    $string = static::lower($string);
    $string = static::ascii($string);
    // replace spaces with simple dashes
    $string = preg_replace('![^' . $allowed . ']!i','-', $string);
    // remove double dashes
    $string = preg_replace('![-]{2,}!','-', $string);
    // trim trailing and leading dashes
    $string = trim($string, '-');
    // replace slashes with dashes
    $string = str_replace('/', '-', $string);
    return $string;
}

Instead of changing the username, maybe think about using the firstName() and lastName() functions on the $user object.

1 Like

I hope I can figure out what I need to change to allow capital letters, but at least I know where to look now. Thank you walkerbox

#All filenames should avoid capital letters!!!

But you can use “First name” and “Last name” to be shown in your templates!

Okay, no reason to get upset.
It’s not about showing in the Templates. It’s about the username.

I don’t care about filenames … if that’s what it’s about then Kirby should still allow the use of capital letters in the username. For the filename it could change it to small letters. The username is used for login purposes and it’s not understandable from a user standpoint to forbid capital letters there.

See, my Username in here is SirNovi … it’s got capital letters and I didnt have to type it twice, once with and once without … no I typed it once and that’s how I login in as well.

1 Like

I agree with you @SirNovi, it should in fact not be too difficult to make a difference between the username and the way the file is saved.

Even if it wouldn’t be possible to both have a user with the username “Tom” and one with the username “tom” in the same installation. At least it should be possible to have the username saved in the file as “Tom” and allow the users to login like that as well…

For backend users it’s not that important but as soon as you start using the system for frontend users (which kirby clearly is made for already) it seems to be a crucial feature which is not available at the moment.

1 Like