loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow setting `redirect_to` cookie on OAuth login (#22594)

The regular login flow can use a `redirect_to` cookie to ensure the user
ends their authentication flow on the same page as where they started
it.

This commit adds the same functionality to the OAuth login URLs, so that
you can use URLs like these to directly use a specific OAuth provider:

`/user/oauth2/{provider}?redirect_to={post-login path}`

Only the `auth.SignInOAuth()` function needed a change for this, as the
rest of the login flow is aware of this cookie and uses it properly
already.

authored by

Sybren and committed by
GitHub
95e8ea94 9cc15d18

+5
+5
routers/web/auth/oauth.go
··· 847 847 return 848 848 } 849 849 850 + redirectTo := ctx.FormString("redirect_to") 851 + if len(redirectTo) > 0 { 852 + middleware.SetRedirectToCookie(ctx.Resp, redirectTo) 853 + } 854 + 850 855 // try to do a direct callback flow, so we don't authenticate the user again but use the valid accesstoken to get the user 851 856 user, gothUser, err := oAuth2UserLoginCallback(authSource, ctx.Req, ctx.Resp) 852 857 if err == nil && user != nil {