|
|
@@ -4,6 +4,9 @@ import (
|
|
|
"encoding/json"
|
|
|
"strings"
|
|
|
|
|
|
+ "dashoo.cn/backend/api/business/logsinfo"
|
|
|
+ "dashoo.cn/business2/auth"
|
|
|
+
|
|
|
"dashoo.cn/backend/api/business/organize"
|
|
|
"dashoo.cn/backend/api/models"
|
|
|
"dashoo.cn/business2/permission"
|
|
|
@@ -34,6 +37,11 @@ type UserModel struct {
|
|
|
Sign string `json:"sign"`
|
|
|
}
|
|
|
|
|
|
+type ChangePwdModel struct {
|
|
|
+ Pwd string `json:"pass"`
|
|
|
+ NwePwd string `json:"newpass"`
|
|
|
+}
|
|
|
+
|
|
|
// @Title get
|
|
|
// @Description get user by token
|
|
|
// @Param uid path string true "The key for staticblock"
|
|
|
@@ -352,3 +360,44 @@ func (this *UserController) Delete() {
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// @Title 修改密码
|
|
|
+// @Description 修改密码
|
|
|
+// @Param body body business.device.DeviceChannels "传感器信息"
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /userchangepwd [put]
|
|
|
+func (this *UserController) UserChangePWD() {
|
|
|
+ var model ChangePwdModel
|
|
|
+ var jsonblob = this.Ctx.Input.RequestBody
|
|
|
+ json.Unmarshal(jsonblob, &model)
|
|
|
+ var errinfo ErrorInfo
|
|
|
+
|
|
|
+ svcauth := auth.GetAuthServic(utils.DBE)
|
|
|
+ var user userRole.Base_User
|
|
|
+
|
|
|
+ if svcauth.VerifyUser3DES(this.User.Username, model.Pwd, &user) {
|
|
|
+ var entitypaw1, entitypaw2 logsinfo.Userpassword
|
|
|
+ idint, _ := utils.StrTo(this.User.Id).Int()
|
|
|
+ var umodel userRole.Base_User = userRole.Base_User{Id: idint}
|
|
|
+ svcauth.UpdateLog(this.User.Id, &entitypaw1, &entitypaw2, this.User.Id, this.User.Realname)
|
|
|
+ err := svcauth.SetNewPassword3DES(&umodel, model.NwePwd)
|
|
|
+ if err != nil {
|
|
|
+ errinfo.Message = "修改失败!" + err.Error()
|
|
|
+ errinfo.Code = -2
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ errinfo.Message = "密码修改成功"
|
|
|
+ errinfo.Code = 0
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ errinfo.Message = "修改失败!当前密码输入错误"
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+}
|