Skip to content

Commit

Permalink
More seed info, login fixes.
Browse files Browse the repository at this point in the history
modified:   app/controllers/api/callbacks_controller.rb
-- fixed missing display_name

modified:   app/models/bookmark.rb
-- made audio_recording_id accessible

modified:   app/models/user.rb
-- allowed either email or display_name

modified:   config/initializers/custom_configs.rb

modified:   db/development_seeds.rb
-- added seed data for bookmarks and saved searches

modified:   db/schema.rb
  • Loading branch information
Mark Cottman-Fields committed Dec 6, 2012
1 parent 1775db4 commit a59883f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/controllers/api/callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ def store_provider_info(canonical_data,resource=nil)
user = authn.user unless authn.blank?
user = User.find_by_email(canonical_data[:email]) if !canonical_data[:email].blank? && user.blank?
user = User.find_by_display_name(canonical_data[:display_name]) if !canonical_data[:display_name].blank? && user.blank?
user = User.create!(:display_name => canonical_data[:display_name], :email => canonical_data[:email], :password => Devise.friendly_token[0,20]) if user.blank?

new_display_name = canonical_data[:display_name]
user = User.create!(:display_name => new_display_name.blank? ? '' : new_display_name, :email => canonical_data[:email], :password => Devise.friendly_token[0,20]) if user.blank?
end

# update display_name if given and it was blank
Expand Down
2 changes: 1 addition & 1 deletion app/models/bookmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Bookmark < ActiveRecord::Base
belongs_to :audio_recording

# attr
attr_accessible :name, :notes, :offset
attr_accessible :name, :notes, :offset, :audio_recording_id

# userstamp
stampable
Expand Down
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class User < ActiveRecord::Base
has_many :permissions

# validation
validates_presence_of :display_name
#validates_presence_of :display_name
validates :display_name, :presence => {:unless => Proc.new { |a| a.email.present? }, :message => "Please provide a display_name, email, or both"}
validates_uniqueness_of :display_name, :email, :case_sensitive => false
#friendly_id :display_name, :use_slug => true, :strip_non_ascii => true
end

0 comments on commit a59883f

Please sign in to comment.