FEAT: oauth2: use link_account page when email/username is missing #1757

Merged
earl-warren merged 5 commits from wetneb/forgejo:1755-oauth2-missing-email into forgejo 2023-11-19 11:50:10 +00:00
Collaborator

This avoids simply failing with an HTTP 500 error instead.
Closes #1755.

This is a work in progress, I am looking for feedback on this approach :)

This avoids simply failing with an HTTP 500 error instead. Closes #1755. <s>This is a work in progress,</s> I am looking for feedback on this approach :) <!-- Before submitting a PR, please read the contributing guidelines: https://codeberg.org/forgejo/forgejo/src/branch/main/CONTRIBUTING.md -->
wetneb added 1 commit 2023-11-12 13:33:46 +00:00
testing / lint-backend (pull_request) Failing after 58s Details
testing / checks-backend (pull_request) Failing after 1m8s Details
testing / test-unit (pull_request) Has been skipped Details
testing / test-mysql (pull_request) Has been skipped Details
testing / test-pgsql (pull_request) Has been skipped Details
testing / test-sqlite (pull_request) Has been skipped Details
a61fc88726
oauth2: use link_account page when email/username is missing
This avoids simply failing with an HTTP 500 error instead.
Closes #1755.
earl-warren added the
enhancement/feature
User Research - feature
labels 2023-11-12 22:46:45 +00:00

I like the idea.

I like the idea.

Heads up: Forgejo is being rebased on Gitea today (that's a weekly occurrence). It means you will need to cherry-pick your commits on top of the newer base branch for this PR and maybe resolve conflicts. You can do that on your own time, you do not need to do that today. It can be in a week or a month and you can keep working in the meantime.

Ideally Gitea would be a package that can be upgraded as any other Go package. But it is not designed in this way and the weekly rebase is the equivalent of such an upgrade, only it is more work.

If you need help doing that, feel free to reach out in the development chatroom.

Heads up: Forgejo is being [rebased on Gitea](https://codeberg.org/forgejo/forgejo/issues?q=Furnace+cleanup) today (that's a weekly occurrence). It means you will need to cherry-pick your commits on top of the newer base branch for this PR and maybe resolve conflicts. You can do that on your own time, you do not need to do that today. It can be in a week or a month and you can keep working in the meantime. Ideally Gitea would be a package that can be upgraded as any other Go package. But it is not designed in this way and the weekly rebase is the equivalent of such an upgrade, only it is more work. If you need help doing that, feel free to reach out in the [development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).
wetneb force-pushed 1755-oauth2-missing-email from a61fc88726 to 54fa881cba 2023-11-14 19:05:43 +00:00 Compare
wetneb force-pushed 1755-oauth2-missing-email from 54fa881cba to 687ad13956 2023-11-14 19:32:17 +00:00 Compare
wetneb force-pushed 1755-oauth2-missing-email from 687ad13956 to c7206910b7 2023-11-14 19:39:41 +00:00 Compare
wetneb added 1 commit 2023-11-14 20:29:37 +00:00
testing / lint-backend (pull_request) Failing after 58s Details
testing / checks-backend (pull_request) Failing after 1m9s Details
testing / test-unit (pull_request) Has been skipped Details
testing / test-mysql (pull_request) Has been skipped Details
testing / test-pgsql (pull_request) Has been skipped Details
testing / test-sqlite (pull_request) Has been skipped Details
215a20078a
Add failing test
wetneb force-pushed 1755-oauth2-missing-email from 215a20078a to ee6885faf0 2023-11-14 20:30:02 +00:00 Compare
wetneb force-pushed 1755-oauth2-missing-email from ee6885faf0 to 50e6c28c6b 2023-11-14 20:36:52 +00:00 Compare
wetneb force-pushed 1755-oauth2-missing-email from 50e6c28c6b to 5f1f6a1ce4 2023-11-14 20:55:01 +00:00 Compare
wetneb changed title from WIP: oauth2: use link_account page when email/username is missing to FEAT: oauth2: use link_account page when email/username is missing 2023-11-14 21:12:51 +00:00
Poster
Collaborator

@earl-warren thanks for the encouragement! I would declare it ready for review then :)

@earl-warren thanks for the encouragement! I would declare it ready for review then :)
wetneb added 1 commit 2023-11-14 21:19:00 +00:00
testing / lint-backend (pull_request) Successful in 2m57s Details
testing / checks-backend (pull_request) Successful in 3m3s Details
testing / test-unit (pull_request) Successful in 6m52s Details
testing / test-mysql (pull_request) Successful in 12m8s Details
testing / test-sqlite (pull_request) Successful in 11m57s Details
testing / test-pgsql (pull_request) Successful in 13m5s Details
8dcdcd5ceb
Remove spurious newline
Gusted reviewed 2023-11-16 21:07:18 +00:00
@ -970,1 +971,3 @@
ctx.ServerError("CreateUser", err)
// we don't have enough information to create an account automatically,
// so we prompt the user for the remaining bits
showLinkingLogin(ctx, gothUser)

I think it's good to add a log.Trace to show which fields were missing.

I think it's good to add a `log.Trace` to show which fields were missing.
Poster
Collaborator

Fair enough, I have added one.

Fair enough, I have added one.
Gusted marked this conversation as resolved
wetneb added 1 commit 2023-11-16 22:52:22 +00:00
testing / lint-backend (pull_request) Successful in 3m0s Details
testing / checks-backend (pull_request) Successful in 2m47s Details
testing / test-unit (pull_request) Successful in 6m14s Details
testing / test-mysql (pull_request) Successful in 11m32s Details
testing / test-sqlite (pull_request) Successful in 11m36s Details
testing / test-pgsql (pull_request) Successful in 12m44s Details
9fa7601a0c
Add trace logging suggested by Gusted
Gusted reviewed 2023-11-18 22:01:15 +00:00
@ -472,0 +473,4 @@
func TestSignUpViaOAuthWithMissingFields(t *testing.T) {
defer tests.PrepareTestEnv(t)()
// enable auto-creation of accounts via OAuth2
setting.OAuth2Client.EnableAutoRegistration = true

This has to be disabled after this.

This has to be disabled after this.
Poster
Collaborator

That's a most excellent point. Did I do it right?

That's a most excellent point. Did I do it right?

Yes, perfect!

Yes, perfect!
Gusted marked this conversation as resolved
wetneb added 1 commit 2023-11-18 22:23:36 +00:00
testing / lint-backend (pull_request) Successful in 2m56s Details
testing / checks-backend (pull_request) Successful in 2m53s Details
testing / test-unit (pull_request) Successful in 7m7s Details
testing / test-mysql (pull_request) Successful in 15m42s Details
testing / test-sqlite (pull_request) Successful in 16m31s Details
testing / test-pgsql (pull_request) Successful in 17m53s Details
f6ca2f749c
Reset the setting after end of test
wetneb force-pushed 1755-oauth2-missing-email from f6ca2f749c to 2d343db363 2023-11-18 22:27:03 +00:00 Compare
wetneb force-pushed 1755-oauth2-missing-email from 2d343db363 to 127a86d452 2023-11-18 22:28:19 +00:00 Compare
Gusted approved these changes 2023-11-19 10:17:44 +00:00
earl-warren merged commit 564e094256 into forgejo 2023-11-19 11:50:10 +00:00

For the record, moved the commit to the forgejo-dependency branch where it belongs.

For the record, [moved the commit](https://codeberg.org/forgejo/forgejo/commit/0f6e0f90359b4b669d297a533de18b41e3293df2) to the `forgejo-dependency` branch where it belongs.
Poster
Collaborator

Thanks, I'll make sure I'll use that branch for my upcoming PRs.

Thanks, I'll make sure I'll use that branch for my upcoming PRs.
wetneb deleted branch 1755-oauth2-missing-email 2023-11-19 11:53:48 +00:00

Thanks! It's perfectly ok to target forgejo if unsure: moving commits around is quite common in the Forgejo workflow.

Thanks! It's perfectly ok to target forgejo if unsure: moving commits around is quite common in [the Forgejo workflow](https://forgejo.org/docs/next/developer/workflow/).
earl-warren added this to the Forgejo v1.22 milestone 2023-11-30 14:17:37 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: forgejo/forgejo#1757
There is no content yet.