Skip to content

Commit

Permalink
fix: 修复登陆注册 token 过期时间错误;更新 http 用例;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Jun 11, 2021
1 parent 2ff1bcc commit 3cd5277
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions http/admin.http
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Content-Type: application/json

{
"username": "less",
"password": "kissme"
"password": "less123"
}

### 管理员信息
Expand All @@ -25,7 +25,7 @@ Authorization: Bearer {{token}}

{
"username": "less-test",
"password": "less-framework",
"password": "less123",
"avatar": "https://work.zhuo-zhuo.com/file/data/23ttprpxmavkkuf6nttc/PHID-FILE-vzv6dyqo3ev2tmngx7mu/logoL)",
"name": "Maslow"
}
Expand Down
2 changes: 1 addition & 1 deletion src/router/admin/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function handleAdminLogin(req: Request, res: Response) {
const admin = ret.data[0]

// 默认 token 有效期为 7 天
const expire = Math.floor(Date.now() / 1000) + 60 * 60 * 1000 * 24 * 7
const expire = Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 7
const payload = {
uid: admin._id,
type: 'admin',
Expand Down
2 changes: 1 addition & 1 deletion src/router/user/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ LoginRouter.post('/login/password', async (req, res) => {
const user = ret.data[0]

// 默认 token 有效期为 7 天
const expire = Math.floor(Date.now() / 1000) + 60 * 60 * 1000 * 24 * 7
const expire = Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 7
const payload = {
uid: user._id,
type: 'user',
Expand Down
2 changes: 1 addition & 1 deletion src/router/user/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ RegisterRouter.post('/register/password', async (req, res) => {


// 注册完成后自动登录,生成 token: 默认 token 有效期为 7 天
const expire = Math.floor(Date.now()) + 60 * 60 * 1000 * 24 * 7
const expire = Math.floor(Date.now()) + 60 * 60 * 24 * 7
const payload = {
uid: r.id,
type: 'user',
Expand Down

0 comments on commit 3cd5277

Please sign in to comment.