-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes pagination; Works again; Also respects pagination setting in th…
…e kandan settings file Signed-off-by: Akash Manohar J <[email protected]>
- Loading branch information
Showing
8 changed files
with
46 additions
and
36 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 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
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
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
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,38 +1,36 @@ | ||
class BushidoUserHooks < Bushido::EventObserver | ||
def user_added | ||
data = params['data'] | ||
puts "Adding a new user with incoming data #{params.inspect}" | ||
puts "Devise username column: #{::Devise.cas_username_column}=" | ||
puts "Setting username to: #{params['data'].try(:[], 'ido_id')}" | ||
|
||
user = User.new(:email => params['data'].try(:[], 'email')) | ||
puts "Devise CAS uniqueID column: #{::Devise.cas_username_column}=" | ||
puts "Setting devise CAS uniqueID to: #{data.try(:[], 'ido_id')}" | ||
|
||
user = User.find_or_initialize_by_ido_id data['ido_id'] | ||
user.email = data['email'] | ||
user.locale = data['locale'] | ||
user.first_name = user.email.split('@').first | ||
user.send("#{::Devise.cas_username_column}=".to_sym, params['data'].try(:[], 'ido_id')) | ||
user.save | ||
end | ||
|
||
def user_removed | ||
puts "Removing user based on incoming data #{params.inspect}" | ||
puts "Devise username column: #{::Devise.cas_username_column}=" | ||
puts "Devise CAS uniqueID column: #{::Devise.cas_username_column}=" | ||
|
||
user = User.find_by_ido_id(params['data']['ido_id']) | ||
|
||
# TODO: Disable the user instead of destroying them (to prevent data loss) | ||
user.update_attribute(:active, false) | ||
end | ||
|
||
def user_updated | ||
puts "Updating user based on incoming data #{params.inspect}" | ||
puts "Devise username column: #{::Devise.cas_username_column}=" | ||
puts "Devise CAS uniqueID column: #{::Devise.cas_username_column}=" | ||
|
||
data = params['data'] | ||
user = User.find_by_ido_id(data['ido_id']) | ||
|
||
if user | ||
# Re-use the CAS login method to set all the extra attributes we | ||
# care about (first_name, last_name, email, local, timezone, | ||
# etc.) | ||
user.bushido_extra_attributes(data) | ||
user.save | ||
end | ||
end | ||
|
||
end |