Social - samuelchen/twido GitHub Wiki

Login with Social account logic

                # 1. anonymous login (first time login with twitter. means also sign up)
                #    profile == sys_profile,
                #    acc.profile == None | acc.profile == sys_profile | acc.profile == user_profile
                # 2. link first time (already login. link in setting)
                #    create acc, profile == user_profile, acc.profile == None
                # 3. link more times (already login. update in setting)
                #    get acc, profile == user_profile,  acc.profile != None, acc.profile == profile
                # 4. link already to other profile (1st time link/login.)
                #    get acc, profile == user_profile | profile == sys_profile,
                #             acc.profile != None, acc.profile != profile, acc.profile != sys_profile
                # 5. login with twitter (not 1st time login)
                #    get acc, profile == sys_profile, acc.profile != None, acc.profile != sys_profile

                # if profile.is_sys:
                #     # anonymous login
                #     if acc.profile is None:
                #         # 1st time login with twitter
                #         acc.profile = profile
                #     elif acc.profile.is_sys:
                #         # 2nd time login with twitter (twitter to ensure this is same user)
                #         pass
                #     else:
                #         # already linked to profile (twitter ensures this is same user)
                #         login(acc.profile.user)
                #         profile = self.get_profile()
                #         pass
                #
                #     # need to create a profile
                #
                # else:
                #     # login already
                #     if acc.profile is None:
                #         # 1st time login with twitter
                #         acc.profile = profile
                #     elif acc.profile.is_sys:
                #         # 2nd time login with twitter (twitter to ensure this is same user)
                #         # last time login with twitter, I did not have a profile. Now I created a profile.
                #         acc.profile = profile
                #     else:
                #         # already linked to profile (twitter ensures this is same user)
                #         # means "update" action (can not link twice).
                #         pass