mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	config option: Require sign in to view repository
This commit is contained in:
		| @@ -42,6 +42,8 @@ RESET_PASSWD_CODE_LIVE_MINUTES = 180 | |||||||
| REGISTER_EMAIL_CONFIRM = false | REGISTER_EMAIL_CONFIRM = false | ||||||
| ; Does not allow register and admin create account only | ; Does not allow register and admin create account only | ||||||
| DISENABLE_REGISTERATION = false | DISENABLE_REGISTERATION = false | ||||||
|  | ; User must sign in to view anything. | ||||||
|  | REQUIRE_SIGNIN_VIEW = false | ||||||
|  |  | ||||||
| [mailer] | [mailer] | ||||||
| ENABLED = false | ENABLED = false | ||||||
|   | |||||||
| @@ -41,6 +41,7 @@ var ( | |||||||
| var Service struct { | var Service struct { | ||||||
| 	RegisterEmailConfirm   bool | 	RegisterEmailConfirm   bool | ||||||
| 	DisenableRegisteration bool | 	DisenableRegisteration bool | ||||||
|  | 	RequireSignInView      bool | ||||||
| 	ActiveCodeLives        int | 	ActiveCodeLives        int | ||||||
| 	ResetPwdCodeLives      int | 	ResetPwdCodeLives      int | ||||||
| } | } | ||||||
| @@ -70,6 +71,7 @@ func newService() { | |||||||
| 	Service.ActiveCodeLives = Cfg.MustInt("service", "ACTIVE_CODE_LIVE_MINUTES", 180) | 	Service.ActiveCodeLives = Cfg.MustInt("service", "ACTIVE_CODE_LIVE_MINUTES", 180) | ||||||
| 	Service.ResetPwdCodeLives = Cfg.MustInt("service", "RESET_PASSWD_CODE_LIVE_MINUTES", 180) | 	Service.ResetPwdCodeLives = Cfg.MustInt("service", "RESET_PASSWD_CODE_LIVE_MINUTES", 180) | ||||||
| 	Service.DisenableRegisteration = Cfg.MustBool("service", "DISENABLE_REGISTERATION", false) | 	Service.DisenableRegisteration = Cfg.MustBool("service", "DISENABLE_REGISTERATION", false) | ||||||
|  | 	Service.RequireSignInView = Cfg.MustBool("service", "REQUIRE_SIGNIN_VIEW", false) | ||||||
| } | } | ||||||
|  |  | ||||||
| func newLogService() { | func newLogService() { | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ func SignInRequire(redirect bool) martini.Handler { | |||||||
| 	return func(ctx *Context) { | 	return func(ctx *Context) { | ||||||
| 		if !ctx.IsSigned { | 		if !ctx.IsSigned { | ||||||
| 			if redirect { | 			if redirect { | ||||||
| 				ctx.Redirect("/") | 				ctx.Redirect("/user/login") | ||||||
| 			} | 			} | ||||||
| 			return | 			return | ||||||
| 		} else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm { | 		} else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm { | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								web.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								web.go
									
									
									
									
									
								
							| @@ -87,7 +87,8 @@ func runWeb(*cli.Context) { | |||||||
|  |  | ||||||
| 	m.Use(middleware.InitContext()) | 	m.Use(middleware.InitContext()) | ||||||
|  |  | ||||||
| 	reqSignIn, ignSignIn := middleware.SignInRequire(true), middleware.SignInRequire(false) | 	reqSignIn := middleware.SignInRequire(true) | ||||||
|  | 	ignSignIn := middleware.SignInRequire(base.Service.RequireSignInView) | ||||||
| 	reqSignOut := middleware.SignOutRequire() | 	reqSignOut := middleware.SignOutRequire() | ||||||
| 	// Routers. | 	// Routers. | ||||||
| 	m.Get("/", ignSignIn, routers.Home) | 	m.Get("/", ignSignIn, routers.Home) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user