Simplifies use of registering_with_oauth in User

Now we just ignore all validations when saving a user for oauth
This commit is contained in:
kikito
2016-04-15 16:29:57 +02:00
parent f776f863bb
commit 3cd12bd6ea

View File

@@ -182,11 +182,11 @@ class User < ActiveRecord::Base
end end
def username_required? def username_required?
!organization? && !erased? && !registering_with_oauth !organization? && !erased?
end end
def email_required? def email_required?
!erased? && !registering_with_oauth !erased?
end end
def has_official_email? def has_official_email?
@@ -215,11 +215,15 @@ class User < ActiveRecord::Base
end end
def save_requiring_finish_signup def save_requiring_finish_signup
self.update(registering_with_oauth: true) begin
end self.registering_with_oauth= true
self.save(validate: false)
def save_requiring_finish_signup_without_email # Devise puts unique constraints for the email the db, so we must detect & handle that
self.update(registering_with_oauth: true, email: nil) rescue ActiveRecord::RecordNotUnique
self.email = nil
self.save(validate: false)
end
true
end end
def ability def ability