Bug when discobot assigns the name in the certificate

Nope this isn’t the case. The bot looks for the user’s Name column and uses that if it exists. Otherwise, it uses the user’s username.

2 Likes

I understand, but in my site there’s no name to set for users (never enabled), only the username.

Hmm that is very odd… I’m assuming you’re on the latest and everything?

If so, can you run the following commands in rails c?

user = User.find_by(username: <your username>)
(user.name && !user.name.blank? ? user.name : user.username).titleize
user = User.find_by(username: Dax)
(user.name && !user.name.blank? ? user.name : user.username).titleize
[1] pry(main)> user = User.find_by(username: Dax)
NameError: uninitialized constant Dax
from (pry):1:in `__pry__'
[2] pry(main)> (user.name && !user.name.blank? ? user.name : user.username).titleize
NoMethodError: undefined method `name' for nil:NilClass
from (pry):2:in `__pry__'
[3] pry(main)>

Oops you need quotes around ‘Dax’

2 Likes

username should be between ', so user = User.find_by(username: 'Dax') for the first line.

2 Likes
user = User.find_by(username: 'Dax')
[1] pry(main)> user = User.find_by(username: 'Dax')
=> #<User:0x0055643d3b5690
 id: 7,
 username: "Dax",
 created_at: Sat, 14 Dec 2013 23:02:47 UTC +00:00,
 updated_at: Sun, 11 Jun 2017 21:20:55 UTC +00:00,
 name: "SupportTeam",
 seen_notification_id: 276379,
 last_posted_at: Sun, 11 Jun 2017 21:20:55 UTC +00:00,
 email: "xxxxx@gmail.com",
 password_hash:
  "826b15de7d524221c26e2xxxxxxxxxxxxxxxxxxxxxxe1cf2",
 salt: "e57b795axxxxxxxxxxx99b74f4",
 active: true,
 username_lower: "dax",
 last_seen_at: Mon, 12 Jun 2017 11:01:58 UTC +00:00,
 admin: true,
 last_emailed_at: Mon, 12 Jun 2017 10:08:24 UTC +00:00,
 trust_level: 4,
 approved: false,
 approved_by_id: nil,
 approved_at: nil,
 previous_visit_at: Sun, 11 Jun 2017 21:20:54 UTC +00:00,
 suspended_at: nil,
[2] pry(main)>
[3] pry(main)> (user.name && !user.name.blank? ? user.name : user.username).titleize
=> "Support Team"
[4] pry(main)>

Changed password hash, email and salt.

Before running the command we have upgraded all again.

In our forum the “name” should be blank because we never set it. And SupportTeam is the name of our first old custom group (set as primary) before we rework all the groups. This group has been deleted for a long time

By chance do you have full name disabled on your site (enable names)? I wonder if a check needs to be made against that site setting too. As I know when we imported, the import set a Full Name on many users, but since we’ve disabled Full Name, they have no way of clearing out the full name that was auto-set via the import.

Yes, it is disabled, but we did not migrate our old forum (it has been closed).

Yeah, I didn’t mean to imply you did. You could have had full name enabled for a short period of time and people had it set, or countless other ways for it to get set. The point was, since you have it disabled, the bot should probably take that into account versus just looking to see if the name property has a value.

2 Likes

Before the site was open to the public I’m pretty sure that our founder disable that setting. Being very attentive to the user privacy, he would never have set a similar setting

In any event, as far as I concerned, I’m sure that I never set a name and certantly, even if I did, it would not be “Support Team”.

But, the point is…there is a way to overwrite the name for all the users to “nil” how are the new registered users ?

 id: 8999,
 username: "Monik_Fatina",
 created_at: Sun, 11 Jun 2017 20:12:40 UTC +00:00,
 updated_at: Sun, 11 Jun 2017 20:12:40 UTC +00:00,
 name: nil,

Way back when, did you do more than CSS when you were working on group titles showing on the user cards?

Relative to the site, yes. Relative to the usernames, probably the answer is yes (I need to check).
Are you suggesting to try the tutorial in the safe-mode without custom css to verify?

That’s why. No bug on the bot.

I’m confused.
It’s not a name , it’s a CSS content that I added:

.username.staff::after, .user-main .fa.fa-shield::before, #user-card .fa.fa-shield::before {
    content: 'SupportTeam';

Are you saying that discourse “read it” as a name and add it to the database?

I’m not convinced of that, as he has enable names disabled, so shouldn’t the bot not even consider full name in that scenario? Regardless if it still has a value.

1 Like

It’s very clear that the bot is not to blame since the real name is in the database, as evidenced by the rails command above.

Of course, the big question remains, how that name got there when enable names has been disabled from the start.

I have a strong feeling that this is a good lead to follow:

Changing the CSS obviously wont write names into the db, but that’s precisely why @Mittineague asked about other activities at the time…

It’s a good question but we are talking of something happened at least 3 or 4 years ago.

It would be interesting to see how many users have a name in the database and when they add it. In this way I can understand at least how long ago were names assigned.

But my knowledge of SQL is zero, I need to ask to my sysadmin.

Yes, I was wondering if while attempting to find a way to have group data show on the user card, a “work-around” was to use the name display. IIRC that was before user cards could display custom fields

1 Like