We have integrated Discourse with another app, and users are managed in Keycloak. When a user deletes his account in the other app, we also delete it via API in Discourse.
Works fine, but the user’s IP is then blocked automatically in Discourse, so there is no way to log in as a different user from the same IP.
Can this IP blocking be turned off? Or make it automatically unblock after some time?
סיכום מבוסס בינה מלאכותית
In a discussion about deleting user accounts via the Discourse API without triggering IP blocking, gschmid reported that deleting users via API automatically blocks their IP, preventing future logins from that IP. Simon_Manning clarified that the API allows control over IP blocking through a block_ip: false flag in the request body — a feature documented in the API docs for deleting users. gschmid confirmed this worked for them. However, Yousab noted that block_email: false did not always prevent email screening, especially for spam-flagged or new users, requiring an additional API call to remove the email from Screened Emails. Simon_Manning suggested the issue might stem from improper JSON formatting, and gschmid advised checking quote usage depending on how the JSON is constructed. Yousab concluded that while block_ip: false reliably prevents IP screening, block_email: false may not always suffice due to edge cases, necessitating manual cleanup of screened emails. The solution hinges on correctly formatting the request body and potentially handling post-deletion cleanup for emails.
Yes. You’ll need to in-check the thing that blocks the ip. See Reverse engineer the Discourse API and see what happens when you do it from the UX.
According to the API documentation for deleting a user, whether it blocks the IP is one of the options passed in with the body of the request.
So in the code where the request is being made, you should be able to provide json in the body of the request which includes ”block_ip”: false.
For example:
{
delete_posts: false,
block_email: false,
block_urls: false,
block_ip: false,
}
I’m not sure if I understand this.
Do you mean I have to unblock the IP via API after the account has been deleted?
I was actually hoping for some configuration switch in Discourse.
Ah, got it. Thanks, will try this.
Hey
Have you gotten your answer here? as ”block_ip”: false, doesn’t work in API request body in my case, so did you have it work or you happen to send another separate request by reverse engineering Discourse API?
It does work for me.
This is our request body:
{
delete_posts: false,
block_email: false,
block_urls: false,
block_ip: false,
}
I wonder if the problem was using "block_ip": false exactly for the request body, as opposed to a JSON object string. I can no longer edit my post but I’ve flagged it to have your JSON added as an example to hopefully make the marked solution clearer.
Thanks for your reply.
We have this in place for the request JSON body {block_email: false} (It’s block_email in our situation), but it doesn’t seem to take effect in user deletion API. We needed to send a separate request to remove the email from the Screened Emails (Blocking Emails).
בהתאם לאופן שבו אתה בונה את מחרוזת ה-JSON שלך (בין אם באופן ידני או עם ספרייה), יכול להיות שתצטרך לנסות בין בחרוזים בודדים, בחרוזים כפולים, או ללא בחרוזים כלל. חוץ מזה, אין לי מושג - ה-API של Discourse בדרך כלל עושה בדיוק את מה שהבטיח.
בסדר, אני אפרסם את זה כאן למי שמתקלל באותה סיטואציה עם API מחיקת המשתמש.
block_ip: False מונע באופן אמין את הוספת ה-IP לרשימות המנוטרים.
block_email: False צריך למנוע את הוספת האימייל לרשימות המנוטרות, אבל כמה מקרים קצה (כמו משתמשים מסומנים כספאם או משתמשים חדשים ברמת TL0) עשויים עדיין לגרום לבדיקה של האימייל גם אם block_email הוא False.
זה ידרוש בקשה נוספת לביטול חומת האימייל מרשימות אימיילים מנוטרים.