-
-
Notifications
You must be signed in to change notification settings - Fork 963
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
feat: Make admin recovery to work without emails #1419 #1750
Conversation
There was a problem hiding this 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}) |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in c6f3d98
persistence/sql/migrations/templates/20210913095309_identity_recovery_tokens.down.fizz
Show resolved
Hide resolved
@@ -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 { |
There was a problem hiding this comment.
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
@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 :/ |
Co-authored-by: Patrik <[email protected]>
There was a problem hiding this 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 }} |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did it help? :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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 |
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! |
…t-email' into issue-1419-admin-recovery-without-email
27f317e
to
0c72018
Compare
@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). |
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 😕
But the good news is, giving access is easy! If the repository belongs to an organization, please add me for the project as a collaborator! |
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Thank you for your hard work! :) |
Related issue(s)
#1419
Checklist
contributing code guidelines.
vulnerability. If this pull request addresses a security. vulnerability, I
confirm that I got green light (please contact
[email protected]) from the maintainers to push
the changes.
works.
Further Comments
It's possible now to initiate and finish the whole recovery flow without a valid recovery email