def change_userpassword(): userid = IdentifyUtil.get_user_id() if not userid: return jsonify(Common.falseReturn(None, 'user not find')) params = request.get_json() if not params.get('oldpassword') or not params.get('newpassword'): return jsonify( Common.falseReturn(None, 'newpassword or oldpassword cannot be empty')) user = UserApi.getUserBase(userid) if user['status'] and user['data'].get( 'password') == IdentifyUtil.hash_secret(params.get('oldpassword')): return jsonify( UserApi.updateUserPassword(userid, params.get('newpassword'))) return jsonify(Common.falseReturn(None, 'check old password wrong'))
def reset_password(): params = request.get_json() if not params.get('emailcode') or not params.get( 'userid') or not params.get('password'): return jsonify( Common.falseReturn( None, 'emailcode and userid and password should not empty')) userbase = UserApi.getUserBase(params.get('userid')) if userbase['status']: userinfo = UserApi.getUserInfoByUserid(userbase['data']['id']) if userinfo['status']: res = ValidEmail.check_validcode_email(userinfo['data']['email'], params.get('emailcode'), 1) if res['status']: return jsonify( UserApi.updateUserPassword(params.get('userid'), params.get('password'))) else: return jsonify(Common.falseReturn(None, 'check code wrong')) else: return jsonify(Common.falseReturn(None, 'get email wrong')) else: return jsonify(Common.falseReturn(None, 'user not exist'))
def get_AllUserBase(): userid = IdentifyUtil.get_user_id() if not userid: return jsonify(Common.falseReturn(None, 'user not find')) return jsonify(UserApi.getUserBase(userid))