generated from root/miduo_server
登陆界面注册按钮删除,root账号初始化改成起服自动执行
parent
e1643a3856
commit
7ac375d649
|
@ -40,7 +40,6 @@ public class WebSecurityConfig extends WebMvcConfigurerAdapter{
|
||||||
addInterceptor.excludePathPatterns("/error");
|
addInterceptor.excludePathPatterns("/error");
|
||||||
addInterceptor.excludePathPatterns("/login**");
|
addInterceptor.excludePathPatterns("/login**");
|
||||||
addInterceptor.excludePathPatterns("/req/**");
|
addInterceptor.excludePathPatterns("/req/**");
|
||||||
addInterceptor.excludePathPatterns("/registerInit");
|
|
||||||
|
|
||||||
addInterceptor.addPathPatterns("/**");
|
addInterceptor.addPathPatterns("/**");
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
@ -50,7 +51,6 @@ public class LoginController {
|
||||||
/**
|
/**
|
||||||
* 登陆验证
|
* 登陆验证
|
||||||
* @param userName
|
* @param userName
|
||||||
* @param password
|
|
||||||
* @param session
|
* @param session
|
||||||
* @param map
|
* @param map
|
||||||
* @return
|
* @return
|
||||||
|
@ -164,26 +164,29 @@ public class LoginController {
|
||||||
* 3: 没有创建账号的身份或者权限
|
* 3: 没有创建账号的身份或者权限
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@PostMapping("/registerInit")
|
@PostConstruct
|
||||||
public @ResponseBody int registerInit() throws Exception {
|
public void registerInit(){
|
||||||
|
try {
|
||||||
|
// 验证账号名是否存在
|
||||||
|
CAdmin admin = cUserDao.findAdmin(ROOT);
|
||||||
|
if (admin != null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 验证账号名是否存在
|
// 初始化
|
||||||
CAdmin admin = cUserDao.findAdmin(ROOT);
|
admin = new CAdmin();
|
||||||
if (admin != null){
|
admin.setUserName(ROOT);
|
||||||
return 0;
|
admin.setPassword("123456");
|
||||||
|
admin.setCreateTime(DateUtil.nowString());
|
||||||
|
|
||||||
|
// root账号处理
|
||||||
|
rootAccount(admin);
|
||||||
|
// 注册,入库
|
||||||
|
cUserDao.registerAdmin(admin);
|
||||||
|
System.out.println("============root账号初始化完成");
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化
|
|
||||||
admin = new CAdmin();
|
|
||||||
admin.setUserName(ROOT);
|
|
||||||
admin.setPassword("123456");
|
|
||||||
admin.setCreateTime(DateUtil.nowString());
|
|
||||||
|
|
||||||
// root账号处理
|
|
||||||
rootAccount(admin);
|
|
||||||
// 注册,入库
|
|
||||||
cUserDao.registerAdmin(admin);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
<div class="formControls col-xs-8 col-xs-offset-3">
|
<div class="formControls col-xs-8 col-xs-offset-3">
|
||||||
<input name="" type="submit" class="btn btn-success radius size-L" value=" 登 录 ">
|
<input name="" type="submit" class="btn btn-success radius size-L" value=" 登 录 ">
|
||||||
<input name="" type="reset" class="btn btn-default radius size-L" value=" 取 消 ">
|
<input name="" type="reset" class="btn btn-default radius size-L" value=" 取 消 ">
|
||||||
<input name="" type="button" onclick="return registerInit()" class="btn btn-primary radius size-L" value=" 注 册 ">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -65,22 +64,6 @@
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerInit() {
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
dataType: "json",
|
|
||||||
contentType: 'application/json',
|
|
||||||
url: "/registerInit",
|
|
||||||
success: function (data) {
|
|
||||||
if (data === 1) {
|
|
||||||
alert("root账号注册成功,密码:123456!");
|
|
||||||
}
|
|
||||||
if (data === 0) {
|
|
||||||
alert("root账号已注册!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue