forked from thoughtbot/clearance
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This setting allows clearance routes to be completely customized. Users who customize the routes to this level may have to edit the views and mailers as there are references to routes there.
- Loading branch information
1 parent
547fb5b
commit 446f41c
Showing
4 changed files
with
72 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
Rails.application.routes.draw do | ||
resources :passwords, | ||
controller: 'clearance/passwords', | ||
only: [:create, :new] | ||
if Clearance.configuration.routes_enabled? | ||
Rails.application.routes.draw do | ||
resources :passwords, | ||
controller: 'clearance/passwords', | ||
only: [:create, :new] | ||
|
||
resource :session, | ||
controller: 'clearance/sessions', | ||
only: [:create] | ||
resource :session, | ||
controller: 'clearance/sessions', | ||
only: [:create] | ||
|
||
resources :users, | ||
controller: 'clearance/users', | ||
only: Clearance.configuration.user_actions do | ||
resource :password, | ||
controller: 'clearance/passwords', | ||
only: [:create, :edit, :update] | ||
end | ||
resources :users, | ||
controller: 'clearance/users', | ||
only: Clearance.configuration.user_actions do | ||
resource :password, | ||
controller: 'clearance/passwords', | ||
only: [:create, :edit, :update] | ||
end | ||
|
||
get '/sign_in' => 'clearance/sessions#new', as: 'sign_in' | ||
delete '/sign_out' => 'clearance/sessions#destroy', as: 'sign_out' | ||
get '/sign_in' => 'clearance/sessions#new', as: 'sign_in' | ||
delete '/sign_out' => 'clearance/sessions#destroy', as: 'sign_out' | ||
|
||
if Clearance.configuration.allow_sign_up? | ||
get '/sign_up' => 'clearance/users#new', as: 'sign_up' | ||
if Clearance.configuration.allow_sign_up? | ||
get '/sign_up' => 'clearance/users#new', as: 'sign_up' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Clearance | ||
class Configuration | ||
attr_writer :allow_sign_up | ||
attr_writer :allow_sign_up, :routes | ||
|
||
attr_accessor \ | ||
:cookie_domain, | ||
|
@@ -21,6 +21,7 @@ def initialize | |
@httponly = false | ||
@mailer_sender = '[email protected]' | ||
@redirect_url = '/' | ||
@routes = true | ||
@secure_cookie = false | ||
@sign_in_guards = [] | ||
end | ||
|
@@ -44,6 +45,10 @@ def user_actions | |
def user_id_parameter | ||
"#{user_model.model_name.singular}_id".to_sym | ||
end | ||
|
||
def routes_enabled? | ||
@routes | ||
end | ||
end | ||
|
||
def self.configuration | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters