设置了账号密码才校验

This commit is contained in:
xugo
2025-08-22 02:33:16 +08:00
parent 92a2d3554a
commit f9f4bb0b02

View File

@@ -40,8 +40,12 @@ type loginOutput struct {
// 登录接口
func (api UserAPI) login(_ *gin.Context, in *loginInput) (*loginOutput, error) {
// 验证用户名和密码
if in.Username != api.conf.Server.Username || in.Password != api.conf.Server.Password {
return nil, reason.ErrNameOrPasswd
if api.conf.Server.Username != "" && api.conf.Server.Password != "" {
api.conf.Server.Username = "admin"
api.conf.Server.Password = "admin"
if in.Username != api.conf.Server.Username || in.Password != api.conf.Server.Password {
return nil, reason.ErrNameOrPasswd
}
}
data := web.NewClaimsData().SetUsername(in.Username)