Skip to content

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

Description

@miftygusein

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions