Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Defined in:
- lib/generators/apit/templates/user.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.new_with_session(params, session) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/generators/apit/templates/user.rb', line 11 def self.new_with_session(params, session) super.tap do |user| if data = session[:omniauth] user.user_tokens.build(:provider => data['provider'], :uid => data['uid']) end end end |
Instance Method Details
#apply_omniauth(omniauth) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/apit/templates/user.rb', line 19 def apply_omniauth(omniauth) #add some info about the user #self.name = omniauth['user_info']['name'] if name.blank? #self.nickname = omniauth['user_info']['nickname'] if nickname.blank? unless omniauth['credentials'].blank? user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid']) #user_tokens.build(:provider => omniauth['provider'], # :uid => omniauth['uid'], # :token => omniauth['credentials']['token'], # :secret => omniauth['credentials']['secret']) else user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid']) end #self.confirm!# unless user.email.blank? end |
#password_required? ⇒ Boolean
36 37 38 |
# File 'lib/generators/apit/templates/user.rb', line 36 def password_required? (user_tokens.empty? || !password.blank?) && super end |