Skip to content

Commit 48dc88a

Browse files
Allow custom redirect for landing page (#19324)
* Allow custom redirect for landing page * Update modules/setting/setting.go Co-authored-by: delvh <[email protected]> * fix lint * one option Co-authored-by: delvh <[email protected]>
1 parent 5ae875a commit 48dc88a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ RUN_MODE = ; prod
237237
;; PPROF_DATA_PATH, use an absolute path when you start gitea as service
238238
;PPROF_DATA_PATH = data/tmp/pprof
239239
;;
240-
;; Landing page, can be "home", "explore", "organizations" or "login"
240+
;; Landing page, can be "home", "explore", "organizations", "login", or any URL such as "/org/repo" or even "https://anotherwebsite.com"
241241
;; The "login" choice is not a security measure but just a UI flow change, use REQUIRE_SIGNIN_VIEW to force users to log in.
242242
;LANDING_PAGE = home
243243
;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
300300
- `ENABLE_GZIP`: **false**: Enable gzip compression for runtime-generated content, static resources excluded.
301301
- `ENABLE_PPROF`: **false**: Application profiling (memory and cpu). For "web" command it listens on localhost:6060. For "serv" command it dumps to disk at `PPROF_DATA_PATH` as `(cpuprofile|memprofile)_<username>_<temporary id>`
302302
- `PPROF_DATA_PATH`: **data/tmp/pprof**: `PPROF_DATA_PATH`, use an absolute path when you start Gitea as service
303-
- `LANDING_PAGE`: **home**: Landing page for unauthenticated users \[home, explore, organizations, login\].
304-
303+
- `LANDING_PAGE`: **home**: Landing page for unauthenticated users \[home, explore, organizations, login, **custom**\]. Where custom would instead be any URL such as "/org/repo" or even "https://anotherwebsite.com"
305304
- `LFS_START_SERVER`: **false**: Enables Git LFS support.
306305
- `LFS_CONTENT_PATH`: **%(APP_DATA_PATH)/lfs**: Default LFS content path. (if it is on local storage.) **DEPRECATED** use settings in `[lfs]`.
307306
- `LFS_JWT_SECRET`: **\<empty\>**: LFS authentication secret, change this a unique string.

modules/setting/setting.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ var (
106106
StaticCacheTime time.Duration
107107
EnableGzip bool
108108
LandingPageURL LandingPage
109+
LandingPageCustom string
109110
UnixSocketPermission uint32
110111
EnablePprof bool
111112
PprofDataPath string
@@ -776,15 +777,19 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
776777
PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
777778
}
778779

779-
switch sec.Key("LANDING_PAGE").MustString("home") {
780+
landingPage := sec.Key("LANDING_PAGE").MustString("home")
781+
switch landingPage {
780782
case "explore":
781783
LandingPageURL = LandingPageExplore
782784
case "organizations":
783785
LandingPageURL = LandingPageOrganizations
784786
case "login":
785787
LandingPageURL = LandingPageLogin
786-
default:
788+
case "":
789+
case "home":
787790
LandingPageURL = LandingPageHome
791+
default:
792+
LandingPageURL = LandingPage(landingPage)
788793
}
789794

790795
if len(SSH.Domain) == 0 {

0 commit comments

Comments
 (0)