# Discourse Category Lockdown

**URL:** https://meta.discourse.org/t/discourse-category-lockdown/70649
**Category:** Plugin
**Tags:** pavilion
**Created:** [September 23, 2017, 9:26pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649 "2017-09-23T21:26:39Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [June 29, 2020, 10:30pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/30 "2020-06-29T22:30:23Z")

</div>

Very easy to configure and I think I have it working properly.

Random question, is it possible to inject a custom icon? i.e. a site logo to use as the icon instead of the font awesome icons? I currently only have it as a png

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [June 30, 2020, 11:51am UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/31 "2020-06-30T11:51:05Z")

</div>

It’s something you can do with some css, I made something similar, but I didn’t keep the code.

If I remember correctly, you need two steps: hiding the custom icon, I used the star icon in my custom theme, then add the custom image before the title

```css
.topic-list .category-idofyourcategory {
    .topic-status .d-icon-star {
        display: none;
    }
    .title::before {
        content: url("/your_image.png");
    }
}

```

I didn’t reproduce it, so you might need to adjust a few things, but it should give you some direction

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [July 15, 2020, 11:47am UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/32 "2020-07-15T11:47:55Z")

</div>

I’m re-directing to a WordPress page (my OAuth provider) which allows the user to sign up for a subscription to view the content, or just login.

The issue is that if they login and go back to the forum, they are not automatically logged into the forum (and have to click the Login button again on the forum). What do I need to change to try to make sure they are automatically logged in? Is there something I can add to my link?

---

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [July 15, 2020, 3:40pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/33 "2020-07-15T15:40:15Z")

</div>

If it allows you to redirect to a url you will want to add this to the end of your discourse url `/session/sso?return_path=/top`, you can change the path it redirects to, but this should log them in for you.

---

<div class="post-metadata">

### Author: ![Solari](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/solari/32/186728_2.png) [@Solari](https://meta.discourse.org/u/Solari)
#### Post date: [July 16, 2020, 11:45pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/34 "2020-07-16T23:45:13Z")

</div>

Outstanding! I used to be able to do this on Xenforo, so I was hoping there would be something similar on Discourse. It’s ideal for paid communities to pull folks into premium portions of the forum.

Many thanks,  
Ray

P.S. @davidkingham David, took a gander at your community. It’s one of the best I have seen. Props and thanks for sharing.

Ray

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [September 5, 2020, 8:12pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/36 "2020-09-05T20:12:12Z")

</div>

This plugin appears to break in 2.6 beta 2. @fzngagan Discourse doesn’t allow me to load any topics when it is activated, see errors below.

> [@Can't load topics](https://meta.discourse.org/t/cant-load-topics/163126):
>
> I recently upgraded my Discourse and now can not seem to load topics. I just get a spinning circle when trying to load the content. URL: [forum.umhoops.com](http://forum.umhoops.com)[This error keeps repeating in the logs](https://pastebin.com/QgbyU51h). In [safe mode](https://meta.discourse.org/t/53504?silent=true), I get this error when trying to load a topic: I’ve rebuilt the container multiple times but that doesn’t seem to fix the issue. The issue started when I tried to upgrade through the web interface a received a bootstrap failed error. I then re-built via SSH and it “w…

```
Message (204 copies reported)

ArgumentError (wrong number of arguments (given 1, expected 0))
lib/topic_view.rb:59:in `initialize'
app/controllers/topics_controller.rb:81:in `new'
app/controllers/topics_controller.rb:81:in `show'
app/controllers/application_controller.rb:340:in `block in with_resolved_locale'
app/controllers/application_controller.rb:340:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:68:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:334:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:22:in `call'
lib/middleware/request_tracker.rb:176:in `call'

Backtrace

plugins/discourse-category-lockdown/plugin.rb:41:in `check_and_raise_exceptions'
lib/topic_view.rb:59:in `initialize'
app/controllers/topics_controller.rb:81:in `new'
app/controllers/topics_controller.rb:81:in `show'
actionpack (6.0.3.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.3.2) lib/abstract_controller/base.rb:195:in `process_action'
actionpack (6.0.3.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.3.2) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.3.2) lib/active_support/callbacks.rb:112:in `block in run_callbacks'
app/controllers/application_controller.rb:340:in `block in with_resolved_locale'

Env

```

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [September 5, 2020, 8:52pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/37 "2020-09-05T20:52:36Z")

</div>

This was also on my list of things to figure out. It seems it was broken by this change (4 days ago)

[https://github.com/discourse/discourse/commit/3b55de90e517f7081006947cc4fabbe5651a65c0#diff-456750b7ffa76d2d60b7bb0b60cb21e6R786](https://github.com/discourse/discourse/commit/3b55de90e517f7081006947cc4fabbe5651a65c0#diff-456750b7ffa76d2d60b7bb0b60cb21e6R786)

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [September 5, 2020, 10:06pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/38 "2020-09-05T22:06:00Z")

</div>

Thanks @RGJ for pointing out the cause.  
I’ll make it a priority and look at this one in my morning time.

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [September 6, 2020, 7:42am UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/39 "2020-09-06T07:42:33Z")

</div>

@davidkingham@RGJ, @dylanb  
Just pushed a fix. Please update and confirm.

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [September 6, 2020, 1:30pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/40 "2020-09-06T13:30:53Z")

</div>

@fzngagan Looks like it is working properly. Thanks for the quick fix.

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [September 10, 2020, 11:03am UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/41 "2020-09-10T11:03:49Z")

</div>

Although the plugin does not crash now, it does not function on tests-passed anymore.

The icon shows but you can access topics within a category as normal.

Just tested this by having a working plugin on 2.5, then moving to tests passed broke it.

Edit this seems like a multisite issue. The check\_and\_raise\_exceptions function is only prepended when the plugin is enabled on multisite master. Also, Discourse needs to be restarted after enabling the plugin.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [September 16, 2020, 11:14am UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/42 "2020-09-16T11:14:09Z")

</div>

I’ve got a question and a request.

Question: how hard would it be to allow crawlers to see the content? I can’t seem to find a way of accessing whether the request is made by a crawler (or the user agent string) from within the guardian for anonymous users. Does anyone have any pointers? I would be happy to create a PR for it if only I knew how to get to this information.

Request: @fzngagan could you please take a look at the multisite issue that was recently introduced? I could make a PR although it would be a trivial change.

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [September 17, 2020, 10:43am UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/43 "2020-09-17T10:43:06Z")

</div>

> [@RGJ](#):
>
> Question: how hard would it be to allow crawlers to see the content? I can’t seem to find a way of accessing whether the request is made by a crawler (or the user agent string) from within the guardian for anonymous users. Does anyone have any pointers? I would be happy to create a PR for it if only I knew how to get to this information.

If you disable javascript in your browser, you can see the crawler layout (hence your users can too 😉 ).  
I’ve made a POC branch named **crawl** which you can test and enchance. If it works, we’ll put it behind a site setting that will be off by default.

Note: I’ve not tested the branch but happy to help 🙂

> [@RGJ](#):
>
> Request: @fzngagan could you please take a look at the multisite issue that was recently introduced? I could make a PR although it would be a trivial change.

I would be happy to accept a PR here. Not familiar with multisite stuff yet 🙂

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [September 17, 2020, 2:36pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/44 "2020-09-17T14:36:22Z")

</div>

I’ve made the pull request.

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [October 31, 2020, 1:54pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/45 "2020-10-31T13:54:36Z")

</div>

Upgraded to the 2.6.0.beta5 version of Discourse and am having another issue with this plugin it looks like. Any ideas @fzngagan?.

When I try to navigate to a “locked down category” as a non-logged in user, I just get a spinning indicator (and am never redirected). It looks like it is adding “You are not permitted to view the requested resource” the URL as well.

 ![image](https://global.discourse-cdn.com/meta/original/3X/2/0/20b073f380069c1a3e5769af5af6760fb082d72f.png)

Here are the example threads:

> **[Subscribers](https://forum.umhoops.com/c/patreon-subscribers/9)**
>
> This section of the forum is for Patreon subscribers only. We'll post Patreon content here along with AMAs and more.

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [November 2, 2020, 3:33pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/46 "2020-11-02T15:33:02Z")

</div>

Anyone have any ideas here?

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [November 3, 2020, 7:28am UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/47 "2020-11-03T07:28:10Z")

</div>

@dylanb  
Yes, I realize this has been broken for some time now and is due a refactor. I’ll take a look at the end of this week most probably.

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [November 3, 2020, 12:41pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/48 "2020-11-03T12:41:56Z")

</div>

Ok – great. Thanks!

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [November 4, 2020, 1:27pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/49 "2020-11-04T13:27:00Z")

</div>

@dylanb  
Here’s my PR for the fix. I’ve asked for a review from @RGJ before merging it in.

[https://github.com/paviliondev/discourse-category-lockdown/pull/10](https://github.com/paviliondev/discourse-category-lockdown/pull/10)

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [November 4, 2020, 3:01pm UTC](https://meta.discourse.org/t/discourse-category-lockdown/70649/50 "2020-11-04T15:01:05Z")

</div>

Awesome – can you post on here when it has been merged in?

[Previous page](https://meta.discourse.org/t/discourse-category-lockdown/70649.md?page=1)

[Next page](https://meta.discourse.org/t/discourse-category-lockdown/70649.md?page=3)
