...
|
...
|
@@ -17,17 +17,42 @@ class Api(ApiTemplate): |
17
|
17
|
try:
|
18
|
18
|
user_guid = int(self.para.get("guid"))
|
19
|
19
|
obj_value = {"company": "company", "email": "email",
|
20
|
|
- "position": "position", "phone": "phone", "password": "pwd"}
|
|
20
|
+ "position": "position", "phone": "phone"}
|
21
|
21
|
|
22
|
22
|
userinfo = User.query.filter_by(id=user_guid)
|
23
|
23
|
if not userinfo.one_or_none():
|
24
|
24
|
res["msg"] = "数据不存在"
|
25
|
25
|
else:
|
|
26
|
+ # 更新密码要求同时输入pwd/newPwd/reNewPwd
|
|
27
|
+ if self.para.__contains__("pwd") or self.para.__contains__("newPwd") or self.para.__contains__("reNewPwd"):
|
|
28
|
+ password = self.para.get("pwd")
|
|
29
|
+ new_password = self.para.get("newPwd")
|
|
30
|
+ re_new_password = self.para.get("reNewPwd")
|
|
31
|
+
|
|
32
|
+ # validate pwd
|
|
33
|
+ if not password:
|
|
34
|
+ res["result"] = False
|
|
35
|
+ res["msg"] = "无原密码"
|
|
36
|
+ return res
|
|
37
|
+ if new_password != re_new_password:
|
|
38
|
+ res["result"] = False
|
|
39
|
+ res["msg"] = "两次输入密码不一致"
|
|
40
|
+ return res
|
|
41
|
+ if userinfo.first().password != password:
|
|
42
|
+ res["result"] = False
|
|
43
|
+ res["msg"] = "原密码输入错误"
|
|
44
|
+ return res
|
|
45
|
+
|
|
46
|
+ # 更新密码
|
|
47
|
+ userinfo.update({"password": new_password})
|
|
48
|
+
|
|
49
|
+ #更新用户基本信息
|
26
|
50
|
for key in obj_value:
|
27
|
51
|
if self.para.__contains__(obj_value[key]):
|
28
|
52
|
value = self.para.get(obj_value[key])
|
29
|
|
- value = value if value is "None" or value is "none" else None
|
|
53
|
+ value = "" if value == "None" or value == "none" else value
|
30
|
54
|
userinfo.update({key: value})
|
|
55
|
+
|
31
|
56
|
db.session.commit()
|
32
|
57
|
res["result"] = True
|
33
|
58
|
res["msg"] = "更新用户信息成功"
|
...
|
...
|
@@ -49,6 +74,16 @@ class Api(ApiTemplate): |
49
|
74
|
"type": "string",
|
50
|
75
|
"description": "密码",
|
51
|
76
|
"required": ""},
|
|
77
|
+ {"name": "newPwd",
|
|
78
|
+ "in": "formData",
|
|
79
|
+ "type": "string",
|
|
80
|
+ "description": "密码",
|
|
81
|
+ "required": ""},
|
|
82
|
+ {"name": "reNewPwd",
|
|
83
|
+ "in": "formData",
|
|
84
|
+ "type": "string",
|
|
85
|
+ "description": "密码",
|
|
86
|
+ "required": ""},
|
52
|
87
|
{"name": "company",
|
53
|
88
|
"in": "formData",
|
54
|
89
|
"type": "string",
|
...
|
...
|
|