/// <summary> /// 判断当前登录的用户密码是否是默认密码,如果是,会让他去修改 /// </summary> /// <param name="userName"></param> /// <returns></returns> public MsgModel IsDefault(string userName) { sys_user sys_user = _baseSysUserService.GetModels(a => a.username == userName).SingleOrDefault(); //判断数据库密码是否是默认密码 var result = PasswordEncoder.IsMatch(sys_user.password, _sysConfigService.GetConfigItem("user.init.password")); //判断数据库密码是否是默认密码 return(MsgModel.Success(result, "获取成功!")); }
/// <summary> /// 个人中心:修改密码 /// </summary> /// <param name="userName"></param> /// <param name="oldPass"></param> /// <param name="newPass"></param> public MsgModel ChangePwd(string userName, string oldPass, string newPass) { sys_user sys_user = _baseSysUserService.GetModels(a => a.username == userName).SingleOrDefault(); // 判断旧密码是否正确 bool isMatch = PasswordEncoder.IsMatch(sys_user.password, oldPass); if (!isMatch) { return(MsgModel.Fail("原密码输入错误,请确认后重新输入!")); } sys_user.password = PasswordEncoder.Encode(newPass); var result = _baseSysUserService.UpdateRange(sys_user); return(result ? MsgModel.Success("密码修改成功!") : MsgModel.Fail("密码修改失败!")); }