I want to use two character usernames but cannot


(Eric Trowbridge) #1

What would the syntax look like to change a user’s username via the console?


#2

@riking did that for me here on this forum (meta discourse) and changed my username from ftudor to just frank…and I am 85% sure he SSH’d in and ran something through Redis (I believe) in the Docker bubble. I have seen simpler way to do one-off SQL database changes from @sam both of the approaches/examples were on a different discourse forum so I won’t link those here. And I cant find a good example to link to on meta.d so perhaps they could chime in?


(Sam Saffron) #3

admins can change usernames unrestricted.

you may need to clean up leftover mentions manually, but that is really an expert mode thing.


(Eric Trowbridge) #4

@sam Thanks man, is it possible to have 2 character user names? I’d like to use my initials, but even after changing the “min_username_length” to 2 and rebuilding the app I still get an error when I try to change it on my profile page.


(lid) #5

Change username via the console will allow you to bypass the JS check.

rails c

u = User.find_by(:username => "old_username") 
u.username = "new_username"
u.save

The minimum length is hard coded on the JS side.


(Sam Saffron) #6

JS check should have parity with what the server enforces. This looks like a bug.

2 letter usernames are not supported really, but a PR to cleanly allow this is fine.


(Eric Trowbridge) #7

Thank you @sam and @Lid! :slight_smile:


(Eric Trowbridge) #8

The Rails code you presented at the top worked like a charm. Much thanks again. :smile:


(lid) #9

https://github.com/discourse/discourse/pull/2838

btw: looks like the onebox gem is not up to date for the pull requests template