Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds an example on how to add a route constrain based on a user for D…

…evise or another warden based authentication system
  • Loading branch information...
commit 53bde57d2d8aae488d1a36f709b3630ef2530b13 1 parent 8a7bb13
@gabceb gabceb authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 README.md
View
20 README.md
@@ -51,6 +51,26 @@ constraints flipper_constraint do
end
```
+Another example of a route constrain using the current_user when using Devise or another warden based authentication system:
+
+```ruby
+# initializers/admin_access.rb
+
+class CanAccessFlipperUI
+ def self.matches?(request)
+ current_user = request.env['warden'].user
+
+ return current_user.present? && current_user.respond_to?(:is_admin?) && current_user.is_admin?
+ end
+end
+
+# config/routes.rb
+
+constraints CanAccessFlipperUI do
+ mount Flipper::UI.app($flipper) => '/flipper'
+end
+```
+
### Standalone
Please sign in to comment.
Something went wrong with that request. Please try again.