2011-12-30 8 views
5

मैं webapp2 से ऑथ मॉड्यूल का उपयोग करता हूं और मैं जानना चाहता हूं कि 'facebook: fbuserid12121212' जैसे auth_id को कैसे जोड़ना है और उसे उपयोगकर्ता के लिए auth_id: s की सूची में जोड़ें। लेकिन मुझे एपीआई से कोई फंक्शन नहीं दिखता है जो मुझे ऐसा करने की इजाजत देता है। क्या आप कृपया मुझे बता सकते हैं कि यह कैसे करें?webapp2 के साथ auth_id कैसे जोड़ें?

धन्यवाद

+1

आपके अपडेट/उत्तर को वास्तविक उत्तर में स्थानांतरित करने के लिए सार्थक हो सकता है (ताकि प्रश्न अनुत्तरित के रूप में दिखाई न दे)। इसे सॉर्ट करने के लिए धन्यवाद :) –

+1

@jgeewax मैंने उत्तर अनुभाग में जवाब स्थानांतरित कर दिया है। – allyourcode

उत्तर

2

यही वह उत्तर है जिसे ओपी मिला। मैं इसे यहाँ प्रतिलिपि बनाई जा रही हूँ ताकि इस सवाल अनुत्तरित नहीं होगा:

This was answered in the google group, समारोह मैं खोज रहा था user.auth_ids.append और कोड मैं अब का उपयोग यह का उपयोग करने के लिए है:

@user_required 
def post(self, **kwargs): 
    email = self.request.POST.get('email') 
    auser = self.auth.get_user_by_session() 
    userid = auser['user_id'] 
    user = auth_models.User.get_by_id(auser['user_id']) 
    existing_user = auth_models.User.get_by_auth_id(email) 

    if existing_user is not None: 
     # You need to handle duplicates. 
     # Maybe you merge the users? Maybe you return an error? 
     pass 

    # Test the uniqueness of the auth_id. We must do this to 
    # be consistent with User.user_create() 
    unique = '{0}.auth_id:{1}'.format(auth_models.__class__.__name__, email) 

    if auth_models.User.unique_model.create(unique): 
     # Append email to the auth_ids list 
     user.auth_ids.append(email) 
     user.put() 
     return "Email updated" 
    else: 
     return 'some error' 
+0

उपयोगकर्ता के लिए auth_id को पुनर्प्राप्त करने के बारे में कैसे? – deltanine

संबंधित मुद्दे