feat: 新增维护模式 + 修复注册关闭页面标题显示问题
- 修复注册关闭时标题“创建账号”和副标题仍显示的问题,三态互斥(维护中 > 关闭注册 > 正常) - 新增 maintenance.enabled 站点设置,默认关闭,仅 Owner 可见可调节 - 维护中间件:全局拦截,维护期间仅站长可访问,白名单放行登录相关路径 - 登录服务:维护期间仅 Owner 角色可登录,Register 优先检查维护状态 - Nav 模板新增维护通知条(黄色横幅) - 管理后台站点设置新增“启用维护模式”开关 - BuildPageData 自动注入 IsMaintenance 到所有页面模板
This commit is contained in:
@ -62,7 +62,11 @@ func (s *AuthService) IsRegistrationEnabled() bool {
|
||||
// rememberMe=true: refresh Cookie 持久化(30天);false: session cookie(关浏览器即清除)
|
||||
// regIP: 注册 IP 地址
|
||||
func (s *AuthService) Register(req model.RegisterRequest, regIP string) (string, string, *model.User, error) {
|
||||
// 0. 检查注册开关
|
||||
// 0. 维护期间禁止注册
|
||||
if s.siteSettings.IsMaintenanceEnabled() {
|
||||
return "", "", nil, common.ErrMaintenanceMode
|
||||
}
|
||||
// 1. 检查注册开关
|
||||
if !s.siteSettings.IsRegistrationEnabled() {
|
||||
return "", "", nil, common.ErrRegistrationDisabled
|
||||
}
|
||||
@ -154,6 +158,11 @@ func (s *AuthService) Login(req model.LoginRequest, loginIP string) (string, str
|
||||
return "", "", nil, common.ErrUserBanned
|
||||
}
|
||||
|
||||
// 维护期间仅站长可登录
|
||||
if s.siteSettings.IsMaintenanceEnabled() && !model.HasMinRole(user.Role, model.RoleOwner) {
|
||||
return "", "", nil, common.ErrMaintenanceMode
|
||||
}
|
||||
|
||||
if !common.CheckPassword(req.Password, user.PasswordHash) {
|
||||
return "", "", nil, common.ErrInvalidCred
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user