generated from root/miduo_server
第一次部署,root账号初始化
parent
7d2f16600d
commit
1045161efd
|
@ -35,6 +35,7 @@ public class WebSecurityConfig extends WebMvcConfigurerAdapter{
|
|||
addInterceptor.excludePathPatterns("/error");
|
||||
addInterceptor.excludePathPatterns("/login**");
|
||||
addInterceptor.excludePathPatterns("/req/**");
|
||||
addInterceptor.excludePathPatterns("/registerInit");
|
||||
|
||||
addInterceptor.addPathPatterns("/**");
|
||||
}
|
||||
|
|
|
@ -155,6 +155,37 @@ public class LoginController {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册初始化
|
||||
* @return
|
||||
* 1: 成功
|
||||
* 0: 账号已存在
|
||||
* 2: session缓存异常
|
||||
* 3: 没有创建账号的身份或者权限
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/registerInit")
|
||||
public @ResponseBody int registerInit() throws Exception {
|
||||
|
||||
// 验证账号名是否存在
|
||||
CAdmin admin = cUserDao.findAdmin(ROOT);
|
||||
if (admin != null){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 初始化
|
||||
admin = new CAdmin();
|
||||
admin.setUserName(ROOT);
|
||||
admin.setPassword("123456");
|
||||
admin.setCreateTime(DateUtil.nowString());
|
||||
|
||||
// root账号处理
|
||||
rootAccount(admin);
|
||||
// 注册,入库
|
||||
cUserDao.registerAdmin(admin);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @param map
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
<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="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>
|
||||
</form>
|
||||
|
@ -63,6 +64,23 @@
|
|||
}
|
||||
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>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue