fix(api): relax account password validation
This commit is contained in:
@@ -19,7 +19,7 @@ import (
|
||||
// LoginRequest 是平台总后台的账号密码登录请求。
|
||||
type LoginRequest struct {
|
||||
Username string `json:"username" binding:"required,max=64"`
|
||||
Password string `json:"password" binding:"required,min=8,max=128"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
}
|
||||
|
||||
// LoginReply 是后台登录成功后的访问凭证与账号状态。
|
||||
@@ -122,8 +122,8 @@ func CurrentProfile(ctx *gin.Context) {
|
||||
|
||||
// ChangePasswordRequest 是已登录账号的改密请求。
|
||||
type ChangePasswordRequest struct {
|
||||
CurrentPassword string `json:"current_password" binding:"required,min=8,max=128"`
|
||||
NewPassword string `json:"new_password" binding:"required,min=12,max=128"`
|
||||
CurrentPassword string `json:"current_password" binding:"required"`
|
||||
NewPassword string `json:"new_password" binding:"required"`
|
||||
}
|
||||
|
||||
// ChangePassword 修改当前账号密码并解除首次登录改密限制。
|
||||
@@ -138,6 +138,10 @@ func ChangePassword(ctx *gin.Context) {
|
||||
infra.Response.Error(ctx, errcode.ErrInvalidArgument)
|
||||
return
|
||||
}
|
||||
if !common.IsValidAccountPassword(request.NewPassword) {
|
||||
infra.Response.Error(ctx, errcode.ErrInvalidArgument)
|
||||
return
|
||||
}
|
||||
var account models.PlatformAccount
|
||||
if err := impl.DBService.Where("identity = ?", claims.Identity).First(&account).Error; err != nil {
|
||||
infra.Response.Error(ctx, errcode.ErrRecordNotFound)
|
||||
|
||||
Reference in New Issue
Block a user