Skip to content

Commit

Permalink
fix: webui login token
Browse files Browse the repository at this point in the history
  • Loading branch information
BIYUEHU committed May 6, 2024
1 parent bf7171b commit 35843e1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions modules/webui/request.http
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@

@URL = http://localhost:720
@KEY = 37cf9b760ffe4928b5bc8552261aa458
@USERNAME = 账号名字
@PASSWORD = 账号密码

### 登录

POST {{URL}}/api/accounts/login HTTP/1.1
Content-Type: application/json

{
"username": "himeno",
"password": "0517"
"username": "{{USERNAME}}",
"password": "{{PASSWORD}}"
}

### 退出登录
Expand Down
2 changes: 1 addition & 1 deletion modules/webui/src/routers/api/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function (ctx: Context, app: Context['server']) {
ctx.webui.setLoginStats(loginStats);
ctx.webui.updateToken();
return res.json({
token: ctx.webui.generateToken,
token: ctx.webui.getToken(),
isDefault: username + password === DEFAULT_USERNAME + DEFAULT_PASSWORD
});
}
Expand Down
4 changes: 2 additions & 2 deletions modules/webui/src/utils/webui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Webui extends Service<Tsu.infer<typeof config>> {
}, 10);
}

public generateToken() {
public getToken() {
return this.ctx.file.load('token', 'txt');
}

Expand All @@ -71,7 +71,7 @@ export class Webui extends Service<Tsu.infer<typeof config>> {
}

public checkToken(token?: string) {
return token && token === `Bearer ${this.generateToken()}`;
return token && token === `Bearer ${this.getToken()}`;
}

public getStats() {
Expand Down
Empty file modified packages/kotori/bin.js
100644 → 100755
Empty file.

0 comments on commit 35843e1

Please sign in to comment.