Skip to content

Commit

Permalink
✨ 新增 debug 模式, 可访问数据库控制台和重置密码
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaojun1998 committed Feb 1, 2021
1 parent 43c12aa commit 3b6e2be
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package im.zhaojun.zfile.controller.admin;


import im.zhaojun.zfile.model.support.ResultBean;
import im.zhaojun.zfile.service.SystemConfigService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;

@Controller
public class DebugController {

@Value("${zfile.debug}")
private Boolean debug;

@Resource
private SystemConfigService systemConfigService;

@GetMapping("/debug/resetPwd")
public ResultBean resetPwd() {
if (debug) {
systemConfigService.updateUsernameAndPwd("admin", "123456");
return ResultBean.success();
} else {
return ResultBean.error("未开启 DEBUG 模式,不允许进行此操作。");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
"name": "zfile.tmp.path",
"type": "java.lang.String",
"description": "临时文件路径."
},
{
"name": "zfile.debug",
"type": "java.lang.Boolean",
"description": "是否开启 debug 模式."
}
]
}
65 changes: 33 additions & 32 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
zfile:
debug: false
log:
path: ${user.home}/.zfile/logs
db:
path: ${user.home}/.zfile/db/zfile
tmp:
path: ${user.home}/.zfile/tmp
cache:
auto-refresh:
interval: 1
timeout: 1800
constant:
readme: readme.md
password: password.txt
preview:
audio:
maxFileSizeMb: 5
text:
maxFileSizeKb: 512
onedrive:
clientId: 09939809-c617-43c8-a220-a93c1513c5d4
clientSecret: _l:[email protected]@B/On6Q
redirectUri: https://zfile.jun6.net/onedrive/callback
scope: offline_access User.Read Files.ReadWrite.All
onedrive-china:
clientId: 4a72d927-1907-488d-9eb2-1b465c53c1c5
clientSecret: Y9CEA=82da5n-y_]KAWAgLH3?R9xf7Uw
redirectUri: https://zfile.jun6.net/onedrive/china-callback
scope: offline_access User.Read Files.ReadWrite.All

server:
port: 8080
servlet:
Expand All @@ -13,7 +44,7 @@ spring:
settings:
web-allow-others: true
path: /h2-console
enabled: false
enabled: ${zfile.debug}
datasource:
# 初始化数据导入
data: classpath*:db/data.sql
Expand Down Expand Up @@ -47,34 +78,4 @@ spring:
chain:
gzipped: true
profiles:
active: prod

zfile:
log:
path: ${user.home}/.zfile/logs
db:
path: ${user.home}/.zfile/db/zfile
tmp:
path: ${user.home}/.zfile/tmp
cache:
auto-refresh:
interval: 1
timeout: 1800
constant:
readme: readme.md
password: password.txt
preview:
audio:
maxFileSizeMb: 5
text:
maxFileSizeKb: 512
onedrive:
clientId: 09939809-c617-43c8-a220-a93c1513c5d4
clientSecret: _l:[email protected]@B/On6Q
redirectUri: https://zfile.jun6.net/onedrive/callback
scope: offline_access User.Read Files.ReadWrite.All
onedrive-china:
clientId: 4a72d927-1907-488d-9eb2-1b465c53c1c5
clientSecret: Y9CEA=82da5n-y_]KAWAgLH3?R9xf7Uw
redirectUri: https://zfile.jun6.net/onedrive/china-callback
scope: offline_access User.Read Files.ReadWrite.All
active: prod

0 comments on commit 3b6e2be

Please sign in to comment.