Je souhaite modifier automatiquement les noms d’utilisateur via l’API afin qu’ils correspondent à l’adresse e-mail.
Notre communauté a pour règle que le nom d’utilisateur doit être prénom.infixe.nom pour un utilisateur dont l’adresse e-mail est prénom.infixe.nom@entreprise.com.
Jusqu’à présent, je modifiais manuellement les noms d’utilisateur peu après l’inscription, via l’interface d’administration, si ceux-ci ne respectaient pas la règle, et je souhaiterais automatiser cela via l’API ou une méthode similaire.
Je n’ai pas trouvé d’appel correspondant dans la documentation de l’API Discourse — la méthode pour renommer un utilisateur est-elle cachée quelque part ?
Existe-t-il une alternative, par exemple, pourrait-on imposer cette règle dès l’inscription ?
If everyone works for the company, the usual solution is to use sso. They way they can’t create the wrong username.
I would like to dig this back up as I have a similar request. I need a newly registered user’s username to be changed to Firstname_Lastname automatically, but I am already using an SSO (Memberful) and they refuse to do this for ‘security concerns’
so I have to do it manually each time a person signs up and inevitably the user emails me about it before I have a chance to change it because it is super boring using only the first name. So is there anyway to to add this as a task? It would of course have to check if the name exists and add a numeral behind it if so. Thanks!
from How does one change a username via the API? - #2 by blake :
Essayez plutôt ce point de terminaison :
curl -i -sS -X PUT "http://127.0.0.1:3000/u/blake/preferences/username.json" \ -H "Content-Type: multipart/form-data;" \ -F "api_key=a66d01fbe98cc51b2747d8bfe99f81d7adca18317fbf3c43aa20f340d8e25bfe" \ -F "api_username=system" \ -F "new_username=blake2"Et cela produira :
{"id":1,"username":"blake2"}