mirror of
https://github.com/thomiceli/opengist.git
synced 2025-06-22 17:57:58 +02:00
Fix empty password error when trying to change the username (#418)
This commit is contained in:
@ -247,3 +247,7 @@ func (dto *UserDTO) ToUser() *User {
|
|||||||
Password: dto.Password,
|
Password: dto.Password,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserUsernameDTO struct {
|
||||||
|
Username string `form:"username" validate:"required,max=24,alphanumdash,notreserved"`
|
||||||
|
}
|
||||||
|
@ -51,11 +51,10 @@ func AccountDeleteProcess(ctx *context.Context) error {
|
|||||||
func UsernameProcess(ctx *context.Context) error {
|
func UsernameProcess(ctx *context.Context) error {
|
||||||
user := ctx.User
|
user := ctx.User
|
||||||
|
|
||||||
dto := new(db.UserDTO)
|
dto := new(db.UserUsernameDTO)
|
||||||
if err := ctx.Bind(dto); err != nil {
|
if err := ctx.Bind(dto); err != nil {
|
||||||
return ctx.ErrorRes(400, ctx.Tr("error.cannot-bind-data"), err)
|
return ctx.ErrorRes(400, ctx.Tr("error.cannot-bind-data"), err)
|
||||||
}
|
}
|
||||||
dto.Password = user.Password
|
|
||||||
|
|
||||||
if err := ctx.Validate(dto); err != nil {
|
if err := ctx.Validate(dto); err != nil {
|
||||||
ctx.AddFlash(validator.ValidationMessages(&err, ctx.GetData("locale").(*i18n.Locale)), "error")
|
ctx.AddFlash(validator.ValidationMessages(&err, ctx.GetData("locale").(*i18n.Locale)), "error")
|
||||||
|
Reference in New Issue
Block a user