Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate verify google account #8620

Merged
merged 2 commits into from
Mar 24, 2021

Conversation

iRhonin
Copy link
Contributor

@iRhonin iRhonin commented Mar 17, 2021

Description

Prevent multiple accounts verify by the same google account in trust tab

Refers/Fixes
  • Added a unique google_user_id to profile model
  • Check for uniqueness of this field on google verification
  • Wrote a migration to populate this field for already existing google connected users and drop google verification for all accounts with duplicate google account.

#7631 (comment)

Testing

@octavioamu
Copy link
Contributor

Hey @iRhonin as the pr for google verification wasn't deployed yet I think we don't need to run the migration right? should it be removed to avoid confusions?

@owocki
Copy link
Contributor

owocki commented Mar 17, 2021

google verification is deployed FYI @octavioamu - checkout your trust bonus tab.

its facebook thats not deployed yet

@octavioamu
Copy link
Contributor

octavioamu commented Mar 17, 2021

google verification is deployed FYI @octavioamu - checkout your trust bonus tab.

its facebook thats not deployed yet

Ohh my bad
PS: I just noted I verified on production with google time ago.

@thelostone-mc thelostone-mc added this to Engineering-Review in PR Review Board Mar 22, 2021
@thelostone-mc thelostone-mc merged commit 1de650f into gitcoinco:master Mar 24, 2021
PR Review Board automation moved this from Engineering-Review to Done Mar 24, 2021
@iRhonin iRhonin deleted the fix-dupplicate-google-trust branch March 24, 2021 11:58
@chibie
Copy link
Contributor

chibie commented Mar 26, 2021

@iRhonin i got this error while running migrations

  Applying dashboard.0174_profile_google_user_id...Traceback (most recent call last):
  File "app/manage.py", line 59, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/django/core/management/commands/migrate.py", line 234, in handle
    fake_initial=fake_initial,
  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/executor.py", line 245, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/code/app/dashboard/migrations/0174_profile_google_user_id.py", line 14, in populate_google_id
    profile.google_user_id = profile.identity_data_google['id']
KeyError: 'id'

i had to change profile.identity_data_google['id'] to profile.identity_data_google.get('id') to successfully run migrations.

i dunno if this failed for anyone else

@iRhonin
Copy link
Contributor Author

iRhonin commented Mar 29, 2021

Hi @chibie,
Did you change is_google_verified directly from DB? (like for testing)

@chibie
Copy link
Contributor

chibie commented Mar 29, 2021

@iRhonin no i didn't

@iRhonin
Copy link
Contributor Author

iRhonin commented Apr 4, 2021

@chibie this is not good, can you share with me is_google_verified and identity_data_google values from your DB to debug more?

@iRhonin
Copy link
Contributor Author

iRhonin commented Apr 19, 2021

Hi @owocki,
I saw you got trouble with this migration, in 0d8a31c and deleted the migration,
can I help you to fix the problem? I did not found any related issue to see what was the problem.

@owocki
Copy link
Contributor

owocki commented Apr 19, 2021 via email

iRhonin added a commit to iRhonin/web that referenced this pull request Apr 23, 2021
* Fix dupplicate verify google account

* Coding style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants