forked from kevadesu/forgejo
[F3] promote F3 users to matching OAuth2 users on first sign-in
This commit is contained in:
parent
f8e1619b99
commit
bd7fef7496
6 changed files with 261 additions and 13 deletions
|
@ -35,6 +35,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/routers"
|
||||
"code.gitea.io/gitea/services/auth/source/f3"
|
||||
"code.gitea.io/gitea/services/auth/source/oauth2"
|
||||
user_service "code.gitea.io/gitea/services/user"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
@ -294,6 +295,21 @@ func authSourcePayloadOIDC(name string) map[string]string {
|
|||
return payload
|
||||
}
|
||||
|
||||
func createF3AuthSource(t *testing.T, name, url, matchingSource string) *auth.Source {
|
||||
assert.NoError(t, auth.CreateSource(&auth.Source{
|
||||
Type: auth.F3,
|
||||
Name: name,
|
||||
IsActive: true,
|
||||
Cfg: &f3.Source{
|
||||
URL: url,
|
||||
MatchingSource: matchingSource,
|
||||
},
|
||||
}))
|
||||
source, err := auth.GetSourceByName(context.Background(), name)
|
||||
assert.NoError(t, err)
|
||||
return source
|
||||
}
|
||||
|
||||
func createUser(ctx context.Context, t testing.TB, user *user_model.User) func() {
|
||||
user.MustChangePassword = false
|
||||
user.LowerName = strings.ToLower(user.Name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue