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

$this->User->welcome() when no first name or username is set #1107

Open
mehov opened this issue Dec 3, 2024 · 0 comments
Open

$this->User->welcome() when no first name or username is set #1107

mehov opened this issue Dec 3, 2024 · 0 comments

Comments

@mehov
Copy link

mehov commented Dec 3, 2024

I'm using cakedc/users on a website where I don't need first names or usernames, I'm only using emails. That breaks $this->User->welcome() because it expects either first name or username:

$title = $identity['first_name'] ?? null;
$title = $title ?: ($identity['username'] ?? null);
$title = is_array($title) ? '-' : (string)$title;
$label = __d(
'cake_d_c/users',
'Welcome, {0}',
$this->AuthLink->link($title, $profileUrl)
);

In my case, the above (predictably) outputs "*Welcome, *".

I acknowledge this is kind of an edge case because I had to specifically hack the Users table rules a little so that it doesn't require a username. But at the same time, I've seen other issues where people want to use email instead of username, and that has even made it into the docs.

So maybe the helper should default to email either if the config says the email is preferred, or if every other way to address the user is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant