mirror of https://github.com/halo-dev/halo
Unencrypt the post password.
parent
cbb2269ce8
commit
ff134941c2
|
@ -2,7 +2,6 @@ package run.halo.app.controller.content;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.PageUtil;
|
import cn.hutool.core.util.PageUtil;
|
||||||
import cn.hutool.crypto.digest.BCrypt;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -185,7 +184,7 @@ public class ContentArchiveController {
|
||||||
throw new ForbiddenException("没有查询到该文章信息");
|
throw new ForbiddenException("没有查询到该文章信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BCrypt.checkpw(password, post.getPassword())) {
|
if (password.equals(post.getPassword())) {
|
||||||
String token = IdUtil.simpleUUID();
|
String token = IdUtil.simpleUUID();
|
||||||
cacheStore.putAny(token, token, 10, TimeUnit.SECONDS);
|
cacheStore.putAny(token, token, 10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
|
|
@ -68,13 +68,7 @@ public class PostParam implements InputConverter<Post> {
|
||||||
thumbnail = "";
|
thumbnail = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Post post = InputConverter.super.convertTo();
|
return InputConverter.super.convertTo();
|
||||||
// Crypt password
|
|
||||||
if (StringUtils.isNotBlank(password)) {
|
|
||||||
post.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return post;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,10 +81,5 @@ public class PostParam implements InputConverter<Post> {
|
||||||
}
|
}
|
||||||
|
|
||||||
InputConverter.super.update(post);
|
InputConverter.super.update(post);
|
||||||
|
|
||||||
// Crypt password
|
|
||||||
if (StringUtils.isNotBlank(password)) {
|
|
||||||
post.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,13 +60,7 @@ public class SheetParam implements InputConverter<Sheet> {
|
||||||
thumbnail = "";
|
thumbnail = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Sheet sheet = InputConverter.super.convertTo();
|
return InputConverter.super.convertTo();
|
||||||
// Crypt password
|
|
||||||
if (StringUtils.isNotBlank(password)) {
|
|
||||||
sheet.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,10 +74,5 @@ public class SheetParam implements InputConverter<Sheet> {
|
||||||
}
|
}
|
||||||
|
|
||||||
InputConverter.super.update(sheet);
|
InputConverter.super.update(sheet);
|
||||||
|
|
||||||
// Crypt password
|
|
||||||
if (StringUtils.isNotBlank(password)) {
|
|
||||||
sheet.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue