Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move providers to SwitchUser::Provider::ProviderName
fixes error raise by SwitchUserController#provider_class autoload wasn't finding the constant Provider Provider wasn't namespaced under SwitchUser, so it was poluting the namespace
- Loading branch information
Showing
12 changed files
with
98 additions
and
88 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,4 +1,4 @@ | ||
require 'provider' | ||
require 'switch_user/provider' | ||
|
||
module SwitchUser | ||
if defined? Rails::Engine | ||
|
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module SwitchUser | ||
module Provider | ||
autoload :Authlogic, "switch_user/provider/authlogic" | ||
autoload :Devise, "switch_user/provider/devise" | ||
autoload :RestfulAuthentication, "switch_user/provider/restful_authentication" | ||
autoload :Sorcery, "switch_user/provider/sorcery" | ||
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module SwitchUser | ||
module Provider | ||
class Authlogic | ||
def initialize(controller) | ||
@controller = controller | ||
end | ||
|
||
def login(user, scope = nil) | ||
UserSession.create(user) | ||
end | ||
|
||
def logout(scope = nil) | ||
@controller.current_user_session.destroy | ||
end | ||
|
||
def current_user(scope = nil) | ||
result = UserSession.find | ||
if result | ||
result.record | ||
end | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module SwitchUser | ||
module Provider | ||
class Devise | ||
def initialize(controller) | ||
@controller = controller | ||
@warden = @controller.warden | ||
end | ||
|
||
def login(user, scope = nil) | ||
@warden.set_user(user, :scope => scope) | ||
end | ||
|
||
def logout(scope = nil) | ||
@warden.logout(scope) | ||
end | ||
|
||
def current_user(scope = nil) | ||
@controller.current_user | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module SwitchUser | ||
module Provider | ||
class RestfulAuthentication | ||
def initialize(controller) | ||
@controller = controller | ||
end | ||
|
||
def login(user, scope = nil) | ||
@controller.current_user = user | ||
end | ||
|
||
def logout(scope = nil) | ||
@controller.logout_killing_session! | ||
end | ||
|
||
def current_user(scope = nil) | ||
@controller.current_user | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module SwitchUser | ||
module Provider | ||
class Sorcery | ||
def initialize(controller) | ||
@controller = controller | ||
end | ||
|
||
def login(user, scope = nil) | ||
@controller.auto_login(user) | ||
end | ||
|
||
def logout(scope = nil) | ||
@controller.logout | ||
end | ||
|
||
def current_user(scope = nil) | ||
@controller.current_user | ||
end | ||
end | ||
end | ||
end |