示例#1
0
 def get_or_create_user_from_authid(self,
                                    auth_id,
                                    email=None,
                                    allow_create=True):
     user = None
     user_with_same_auth_id = EnkiModelUser.get_by_auth_id(auth_id)
     if user_with_same_auth_id:
         # if a user with the same auth id already exists but has a blank email: add the email to the account.
         # note: if the account has an email or they've removed their email, we don't overwrite it.
         if email and user_with_same_auth_id.email == None:
             user = self.set_email(email, user_with_same_auth_id.key.id())
         else:
             user = user_with_same_auth_id
     if not user and allow_create:
         # create a new user
         user = EnkiModelUser(email=email, auth_ids_provider=[auth_id])
         user.put()
     return user