-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
… Session. Fixes sreg support so it supports any amount of sreg fields. Signed-off-by: Ben Johnson <bjohnson@binarylogic.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,8 @@ def openid_identifier=(value) | |
# if their OpenID provider supports it. | ||
def save(perform_validation = true, &block) | ||
return false if perform_validation && block_given? && authenticate_with_openid? && !authenticate_with_openid | ||
|
||
return false if new_record? && !openid_complete? | ||
result = super | ||
yield(result) if block_given? | ||
result | ||
|
@@ -90,7 +92,7 @@ def authenticate_with_openid | |
options = {} | ||
options[:required] = self.class.openid_required_fields | ||
options[:optional] = self.class.openid_optional_fields | ||
options[:return_to] = session_class.controller.url_for(:for_model => "1") | ||
options[:return_to] = session_class.controller.url_for(:for_model => "1",:controller=>"users",:action=>"create") | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
herestomwiththeweather
|
||
|
||
session_class.controller.send(:authenticate_with_open_id, openid_identifier, options) do |result, openid_identifier, registration| | ||
if result.unsuccessful? | ||
|
@@ -102,7 +104,6 @@ def authenticate_with_openid | |
|
||
return true | ||
end | ||
|
||
return false | ||
end | ||
|
||
|
@@ -112,9 +113,13 @@ def authenticate_with_openid | |
# Basically you will get a hash of values passed as a single argument. Then just map them as you see fit. Check out | ||
# the source of this method for an example. | ||
def map_openid_registration(registration) # :doc: | ||
self.name ||= registration[:fullname] if respond_to?(:name) && !registration[:fullname].blank? | ||
self.first_name ||= registration[:fullname].split(" ").first if respond_to?(:first_name) && !registration[:fullname].blank? | ||
self.last_name ||= registration[:fullname].split(" ").last if respond_to?(:last_name) && !registration[:last_name].blank? | ||
registration.symbolize_keys! | ||
[self.class.openid_required_fields+self.class.openid_optional_fields].flatten.each do |field| | ||
setter="#{field.to_s}=".to_sym | ||
if respond_to?(setter) | ||
send setter,registration[field] | ||
end | ||
end | ||
end | ||
|
||
# This method works in conjunction with map_saved_attributes. | ||
|
3 comments
on commit 23c5f5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting validation errors, the one about password bugs me since it's not needed while using OpenID:
4 errors prohibited this user from being saved
There were problems with the following fields:
Login is too short (minimum is 3 characters)
Login should use only letters, numbers, spaces, and .-_@ please.
Password is too short (minimum is 4 characters)
Password confirmation is too short (minimum is 4 characters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at my fork (http://github.com/mreinsch/authlogic_openid/), there is an alternative implementation based on patches by gaizka and cpjolicoeur.
Regarding the login, please have a look at the readme, step 5. The password field is already handled by authlogic_openid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at my fork (http://github.com/mreinsch/authlogic_openid), I'm using an implementation based on patches by gaizka and cpjolicoeur. Regarding the login field, have a look at the readme, Step 5. The password field is already taken care of by authlogic_openid.
Why is :controller=>"users",:action=>"create" hardcoded?