From 519b91ad2da231c26890ee601ad1d089d26bf351 Mon Sep 17 00:00:00 2001
From: rekayno <92271828+rekayno@users.noreply.github.com>
Date: Mon, 23 Jan 2023 23:57:57 +0300
Subject: [PATCH 1/3] link update in README files (#22582)
Co-authored-by: KN4CK3R
---
README.md | 8 ++++----
README_ZH.md | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 19703d85dd..29d5371a36 100644
--- a/README.md
+++ b/README.md
@@ -12,14 +12,14 @@
-
+
-
-
+
+
@@ -45,7 +45,7 @@
-
+
diff --git a/README_ZH.md b/README_ZH.md
index 0e58ad6d4a..285a814037 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -12,14 +12,14 @@
-
+
-
-
+
+
@@ -45,7 +45,7 @@
-
+
From 9cc15d18dfe25f5e0a7569ffb6203e9a4dbb2404 Mon Sep 17 00:00:00 2001
From: John Olheiser
Date: Mon, 23 Jan 2023 15:51:18 -0600
Subject: [PATCH 2/3] Project links should use parent link methods (#22587)
Instead of re-creating, these should use the available `Link` methods
from the "parent" of the project, which also take sub-urls into account.
Signed-off-by: jolheiser
---
models/project/project.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/models/project/project.go b/models/project/project.go
index 8bac9115ba..273823ac9d 100644
--- a/models/project/project.go
+++ b/models/project/project.go
@@ -123,7 +123,7 @@ func (p *Project) Link() string {
log.Error("LoadOwner: %v", err)
return ""
}
- return fmt.Sprintf("/%s/-/projects/%d", p.Owner.Name, p.ID)
+ return fmt.Sprintf("%s/-/projects/%d", p.Owner.HomeLink(), p.ID)
}
if p.RepoID > 0 {
err := p.LoadRepo(db.DefaultContext)
@@ -131,7 +131,7 @@ func (p *Project) Link() string {
log.Error("LoadRepo: %v", err)
return ""
}
- return fmt.Sprintf("/%s/projects/%d", p.Repo.RepoPath(), p.ID)
+ return fmt.Sprintf("%s/projects/%d", p.Repo.Link(), p.ID)
}
return ""
}
From 95e8ea944097ca14d21f2b2a2601f85c28e1cd7c Mon Sep 17 00:00:00 2001
From: Sybren <122987084+drsybren@users.noreply.github.com>
Date: Tue, 24 Jan 2023 17:41:38 +0100
Subject: [PATCH 3/3] 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.
---
routers/web/auth/oauth.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index 3d70ca9a50..be60a0c73b 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -847,6 +847,11 @@ func SignInOAuth(ctx *context.Context) {
return
}
+ redirectTo := ctx.FormString("redirect_to")
+ if len(redirectTo) > 0 {
+ middleware.SetRedirectToCookie(ctx.Resp, redirectTo)
+ }
+
// try to do a direct callback flow, so we don't authenticate the user again but use the valid accesstoken to get the user
user, gothUser, err := oAuth2UserLoginCallback(authSource, ctx.Req, ctx.Resp)
if err == nil && user != nil {