Halo 开源项目学习(三):注册与登录

Java100

基本介绍

首次启动 Halo 项目时需要安装博客并注册用户信息,当博客安装完成后用户就可以根据注册的信息登录到管理员界面,下面我们分析一下整个过程中代码是如何执行的。

博客安装

项目启动成功后,我们可以访问 http://127.0.0.1:8090 进入到博客首页,或者访问 http://127.0.0.1:8090/admin 进入到管理员页面。但如果博客未安装,那么页面会被重定向到安装页面:

Halo 开源项目学习(三):注册与登录

这是因为 Halo 中定义了几个过滤器,分别为 ContentFilter、ApiAuthenticationFilter 和 AdminAuthenticationFilter。这三个过滤器均为 AbstractAuthenticationFilter 的子类,而 AbstractAuthenticationFilter 又继承自 OncePerRequestFilter,其重写的 doFilterInternal 方法如下:

```java
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
FilterChain filterChain) throws ServletException, IOException {
// Check whether the blog is installed or not
Boolean isInstalled =
optionService
.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false);

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长