]> source.dussan.org Git - gitea.git/commit
Improve oauth2 client "preferred username field" logic and the error handling (#30622)
authorwxiaoguang <wxiaoguang@gmail.com>
Thu, 25 Apr 2024 11:22:32 +0000 (19:22 +0800)
committerGitHub <noreply@github.com>
Thu, 25 Apr 2024 11:22:32 +0000 (11:22 +0000)
commitbffbbf547063fa170cc52ae2e757d5badb336632
treede5e17bfdbc504c7c9788ebcd09978340e241b40
parentd0bfc978de802683b9a44720b7f5a8a8394d38be
Improve oauth2 client "preferred username field" logic and the error handling (#30622)

Follow #30454
And fix #24957

When using "preferred_username", if no such field,
`extractUserNameFromOAuth2` (old `getUserName`) shouldn't return an
error. All other USERNAME options do not return such error.

And fine tune some logic and error messages, make code more stable and
more friendly to end users.
16 files changed:
custom/conf/app.example.ini
docs/content/administration/config-cheat-sheet.en-us.md
models/unittest/testdb.go
models/user/user.go
models/user/user_test.go
modules/session/mock.go [new file with mode: 0644]
modules/session/store.go
modules/setting/oauth2.go
options/locale/locale_en-US.ini
routers/web/auth/auth.go
routers/web/auth/auth_test.go
routers/web/auth/linkaccount.go
routers/web/auth/oauth.go
services/context/context.go
services/contexttest/context_tests.go
templates/user/auth/link_account.tmpl