lib/generators/domp/templates/model_authentication.rb in domp-0.0.4 vs lib/generators/domp/templates/model_authentication.rb in domp-0.0.5

- old
+ new

@@ -8,15 +8,17 @@ <% if Rails::VERSION::MAJOR < 4 -%> attr_accessible "#{class_name.downcase}_id", :authentication_provider_id, :uid, :token, :token_expires_at, :params <% end -%> def self.create_from_omniauth(params, <%= class_name.downcase %>, provider) + token_expires_at = params['credentials']['expires_at'] ? Time.at(params['credentials']['expires_at']).to_datetime : nil + create( <%= class_name.downcase %>: <%= class_name.downcase %>, authentication_provider: provider, uid: params['uid'], token: params['credentials']['token'], - token_expires_at: Time.at(params['credentials']['expires_at']).to_datetime, + token_expires_at: token_expires_at, params: params, ) end end <% end -%> \ No newline at end of file