mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Fix prohibit login check on authorization (#6106)
* fix bug prohibit login not applied on dashboard * fix tests * fix bug user status leak * fix typo * return after render
This commit is contained in:
		@@ -8,6 +8,7 @@ import (
 | 
			
		||||
	"net/url"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/modules/auth"
 | 
			
		||||
	"code.gitea.io/gitea/modules/log"
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
	"github.com/go-macaron/csrf"
 | 
			
		||||
	macaron "gopkg.in/macaron.v1"
 | 
			
		||||
@@ -32,8 +33,12 @@ func Toggle(options *ToggleOptions) macaron.Handler {
 | 
			
		||||
 | 
			
		||||
		// Check prohibit login users.
 | 
			
		||||
		if ctx.IsSigned {
 | 
			
		||||
 | 
			
		||||
			if ctx.User.ProhibitLogin {
 | 
			
		||||
			if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
 | 
			
		||||
				ctx.Data["Title"] = ctx.Tr("auth.active_your_account")
 | 
			
		||||
				ctx.HTML(200, "user/auth/activate")
 | 
			
		||||
				return
 | 
			
		||||
			} else if !ctx.User.IsActive || ctx.User.ProhibitLogin {
 | 
			
		||||
				log.Info("Failed authentication attempt for %s from %s", ctx.User.Name, ctx.RemoteAddr())
 | 
			
		||||
				ctx.Data["Title"] = ctx.Tr("auth.prohibit_login")
 | 
			
		||||
				ctx.HTML(200, "user/auth/prohibit_login")
 | 
			
		||||
				return
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user