working ember... again

This commit is contained in:
2013-10-07 23:00:01 +02:00
parent a8c01d264e
commit 2f41560591
46 changed files with 274 additions and 114 deletions
+27 -1
View File
@@ -5,7 +5,14 @@ class User
property :active_list_id
property :admin, type: :boolean, default: false
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :token_authenticatable # , :registerable
#FACEBOOK
property :provider
property :uid
property :oauth_token
property :oauth_expires_at
property :auth_data
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :token_authenticatable, :omniauthable, :omniauth_providers => [:facebook] # , :registerable
property :authentication_token
@@ -17,6 +24,25 @@ class User
view :by_authentication_token, key: :authentication_token
view :by_email, key: :email
view :by_facebook, key: [:provider, :uid]
def self.find_for_facebook_oauth(auth_data, user)
user = database.view(self.by_facebook(key: [auth_data.provider, auth_data.uid], limit: 1)).first
user || create(
provider: auth_data.provider,
uid: auth_data.uid,
name: auth_data.info.nickname,
email: auth_data.info.email,
password: Devise.friendly_token[0,20],
oauth_token: user.oauth_token = auth.credentials.token,
oauth_expires_at: Time.at(auth_data.credentials.expires_at),
auth_data: auth_data
)
end
def self.from_omniauth(auth)
binding.pry
end
def list_is_closed!
self.active_list_id = nil