# Groups can be given same name as existing username

**URL:** https://meta.discourse.org/t/groups-can-be-given-same-name-as-existing-username/74010
**Category:** Bug
**Created:** [13 نوفمبر 2017، 9:00م UTC](https://meta.discourse.org/t/groups-can-be-given-same-name-as-existing-username/74010 "2017-11-13T21:00:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [13 نوفمبر 2017، 9:00م UTC](https://meta.discourse.org/t/groups-can-be-given-same-name-as-existing-username/74010/1 "2017-11-13T21:00:23Z")

</div>

> [@Changing Username Stops Email Notifications](https://meta.discourse.org/t/changing-username-stops-email-notifications/69799/15):
>
> That’s definitely not recommended. Groups and users share a namespace. I don’t even think that’s supposed to be possible.

I just came across this on my site - it is indeed possible to create a group with the same name as an existing username. Chaos ensues.

(Actually, not sure about the chaos - we had this situation for months before I noticed it today)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [13 نوفمبر 2017، 9:12م UTC](https://meta.discourse.org/t/groups-can-be-given-same-name-as-existing-username/74010/2 "2017-11-13T21:12:43Z")

</div>

I think the reverse is also true, @tgxworld can you add this to your list, we definitely want to sort it out so usernames and groups can never share the same name.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2 أبريل 2018، 10:27ص UTC](https://meta.discourse.org/t/groups-can-be-given-same-name-as-existing-username/74010/10 "2018-04-02T10:27:53Z")

</div>

I’ve added the missing server side validations for now in

[https://github.com/discourse/discourse/commit/221503cd10d1421f1a0e02931c034d6cd468e57c](https://github.com/discourse/discourse/commit/221503cd10d1421f1a0e02931c034d6cd468e57c)

@sam I’m unsure about how we should proceed here with regards to the database constraints though, do you think it is worth extracting `User#username` and `Group#name` into a separate table? Those two columns are used frequently so having to join on another table might be expensive. Instead of splitting into another table, I was thinking of treating `Group#name` as having a lower priority than `User#username`. We’ll just run a periodic job that ensures that no group names would clash with a user. If someone manages to sneak a group named  
`test` past our server side validations when a user `test` already exists, the job would just rename the group to `test1`.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [12 يونيو 2018، 8:07ص UTC](https://meta.discourse.org/t/groups-can-be-given-same-name-as-existing-username/74010/11 "2018-06-12T08:07:07Z")

</div>

3 posts were split to a new topic: [Add support for Groups and Usernames that completely overlap](https://meta.discourse.org/t/add-support-for-groups-and-usernames-that-completely-overlap/89661)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [12 يونيو 2018، 8:08ص UTC](https://meta.discourse.org/t/groups-can-be-given-same-name-as-existing-username/74010/12 "2018-06-12T08:08:28Z")

</div>

I am assuming this is now sorted, so I am closing it.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [12 يونيو 2018، 8:08ص UTC](https://meta.discourse.org/t/groups-can-be-given-same-name-as-existing-username/74010/13 "2018-06-12T08:08:30Z")

</div>


