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

feat: Make admin recovery to work without emails #1419 #1750

Merged
merged 24 commits into from
Oct 29, 2021

Conversation

abador
Copy link
Contributor

@abador abador commented Sep 14, 2021

Related issue(s)

#1419

Checklist

Further Comments

It's possible now to initiate and finish the whole recovery flow without a valid recovery email

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks much more like what we need! I haven’t vetted the tests yet but the logic looks 👌. The SQL statements need a bit more work but generally it appears to be good to go. Could you please also update the docs a bit that talk about this feature to reflect the new behavior? :)

@@ -0,0 +1,2 @@
add_column("identity_recovery_tokens", "identity_id", "uuid", {"size": 36})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a foreign key :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c6f3d98

@@ -75,12 +74,10 @@ func (p *Persister) UseRecoveryToken(ctx context.Context, token string) (*link.R
}

var ra identity.RecoveryAddress
if err := tx.Where("id = ? AND nid = ?", rt.RecoveryAddressID, nid).First(&ra); err != nil {
return sqlcon.HandleError(err)
if err := tx.Where("id = ? AND nid = ?", rt.RecoveryAddressID, nid).First(&ra); err == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any error would be ignored here. Please return them appropriately. You can use errors.Is(sql.ErrNoRows) to detect if the row could not be found

@abador abador changed the title Make admin recovery to work without emails, #1419 Make admin recovery to work without emails #1419 Sep 15, 2021
@abador abador changed the title Make admin recovery to work without emails #1419 feat: Make admin recovery to work without emails #1419 Sep 15, 2021
@abador
Copy link
Contributor Author

abador commented Sep 15, 2021

@aeneasr I pushed the fixes and docs. Still the tests fail on running goimports. I'm not sure why this fails since I've got it configured locally and I see no errors :/

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost :)

"on_delete": "CASCADE",
"on_update": "RESTRICT",
})
{{ end }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add foreign keys in sqlite like so:

sql("ALTER TABLE selfservice_login_flows ADD COLUMN nid CHAR(36) NULL REFERENCES networks(id) ON DELETE CASCADE ON UPDATE RESTRICT")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry missed that comment. I'll try to fix it today

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aeneasr if I add a column this way the migrations don't generate properly. The identity_id column is added i one of the first migrations and then is being removed after some temp table is generated and data is copied there. This causes tests to fail since the identity_id column doesn't exist
"sqlite create: table identity_recovery_tokens has no column named identity_id"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you share the full up/down migration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did it help? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry @aeneasr no it didn't. I still get "sqlite create: table identity_recovery_tokens has no column named identity_id" . The only change that wasn't in the pr is in this file: 20210410175418000063_network.sqlite3.down.sql, but it doesn't matter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll take a look

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked out your branch, ran rm -rf persistence/sql/migrations/sql/* && make migrations-render-replace and it worked. Not sure what's going on on your end?

Assuming tests pass, is this PR complete in your opinion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked out your branch, ran rm -rf persistence/sql/migrations/sql/* && make migrations-render-replace and it worked. Not sure what's going on on your end?

Assuming tests pass, is this PR complete in your opinion?

make migrations-render-replace works, but tests fail after that the same way. After regenerating migrations the only difference between my pr and local changes is the file I mentioned in the previous comment.

As for the PR I would say it's finished.

@aeneasr
Copy link
Member

aeneasr commented Oct 12, 2021

I have fixed the issues you faced. However, there are still a few tests failing. Those are related to your changes though. Could you please take a look? Thanks!

@abador
Copy link
Contributor Author

abador commented Oct 14, 2021

I have fixed the issues you faced. However, there are still a few tests failing. Those are related to your changes though. Could you please take a look? Thanks!

Sorry @aeneasr I'll get back to all upstream tickets on friday or next week

@aeneasr aeneasr marked this pull request as draft October 20, 2021 12:08
@aeneasr
Copy link
Member

aeneasr commented Oct 20, 2021

While the PR is being worked on I will mark it as a draft. That declutters our review backlog :)

Once you're done with your changes and would like someone to review them, mark the PR as ready and request a review from one of the maintainers.

Thank you!

@abador abador force-pushed the issue-1419-admin-recovery-without-email branch from 27f317e to 0c72018 Compare October 26, 2021 21:19
@abador abador marked this pull request as ready for review October 27, 2021 05:17
@abador
Copy link
Contributor Author

abador commented Oct 27, 2021

@aeneasr it seems one test failed, but it's unrelated to my changes (I did a squash and git push force yesterday when everything passed except ci/circleci: generate-openapi).

@aeneasr
Copy link
Member

aeneasr commented Oct 27, 2021

I tried pushing some changes required for merging the PR to your fork & branch, but it appears that I am not allowed to do so 😕

% git push ...
ERROR: Permission to push denied to aeneasr.
fatal: could not read from the remote repository.

Please make sure that you have the correct access rights
and the repository exists.

But the good news is, giving access is easy! ☺️ All you need to do is enable write access for maintainers. Thank you! 😄

If the repository belongs to an organization, please add me for the project as a collaborator!

@codecov
Copy link

codecov bot commented Oct 28, 2021

Codecov Report

Merging #1750 (9bfe61e) into master (833f14f) will increase coverage by 0.00%.
The diff coverage is 92.59%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1750   +/-   ##
=======================================
  Coverage   75.13%   75.13%           
=======================================
  Files         292      292           
  Lines       15125    15127    +2     
=======================================
+ Hits        11364    11366    +2     
  Misses       2950     2950           
  Partials      811      811           
Impacted Files Coverage Δ
persistence/sql/persister_recovery.go 80.00% <0.00%> (+0.45%) ⬆️
selfservice/strategy/link/strategy_recovery.go 64.15% <100.00%> (-0.93%) ⬇️
selfservice/strategy/link/test/persistence.go 100.00% <100.00%> (ø)
selfservice/strategy/link/token_recovery.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 273785a...9bfe61e. Read the comment docs.

@aeneasr aeneasr merged commit db00e85 into ory:master Oct 29, 2021
@aeneasr
Copy link
Member

aeneasr commented Oct 29, 2021

Thank you for your hard work! :)

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

Successfully merging this pull request may close these issues.

4 participants