כיצד לבטל גישה מבלי לשלוח דוא"ל למשתמש

Hi.

My forum is on version 2.7.0.beta6.

I maintain an employee forum where we want to disable access to specific users without emailing them. The way we have been disabling access is by suspending their account. When we suspend their account the user receives an email containing the reason for suspension. We’d really rather not bother the person with an email.

I’ve tried first deactivating a test account before suspending it, but an email is still sent.

Note: when I suspend a user, I am not filing in the “Email message” field with anything.

Is there a way I can disable access to Discourse without emailing the user?

- Ryan

2 לייקים

Here’s some code that will do it at the rails console:

./launcher enter app 
rails c
username = "user-to-suspend-username"
admin_username = "admin-username"
reason = "suspend reason"
till = Time.at(33174889200)
u = User.find_by_username(username)
puts "couldn't find user named #{username}" unless u
if u and !u.suspended?
  u.suspended_till = till
  u.suspended_at = DateTime.now

  User.transaction do
    u.save!
    admin = User.find_by_username(admin_username)
    StaffActionLogger.new(admin).log_user_suspend(
      u,
      reason
    )
  end
  u.logged_out
end
לייק 1

If the person is no longer an employee, how are they still able to access their corporate email account? :thinking:

You could always edit the user first, change their email to no@email.some.random.nonexistent.domain

And then suspend them.

לייק 1

It uses personal emails.

I know how to do that at the Rails console, but is there a way to do that in Web UI? I see the option to edit their email in their profile, but it looks like it requires the email to be verified before it takes effect.

לייק 1

Wasn’t the emailing optional before?

3 לייקים

All the documentation makes it look that way! But, it sends an email even if you leave the message part blank.

https://docs.discourse.org/#tag/Users/paths/~1admin~1users~1{id}~1suspend.json/put

Will send an email with this message when present

Optionally, provide more information about the suspension and it will be emailed to the user

2 לייקים

You’re right, I just tested that. And deactivating the user’s email doesn’t prevent the email from going out either. I could have sworn that no email was sent unless the optional message was added in past versions.

2 לייקים

I’ve started a pull request to bring behavior in line with documentation:

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

6 לייקים

This fix has been merged by @eviltrout :tada:

2 לייקים

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.