feat: 完成用户登录界面,api还需完善
This commit is contained in:
1 parent
4c69f57aaa
commit
d7dcc473a9
18 files changed
+681
-129
No files matched your search
@@ -2,6 +2,8 @@
|
||||
import bcrypt from 'bcryptjs';
|
||||
import BetterSqlite3 from 'better-sqlite3';
|
||||
|
||||
// 暂未实现
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event);
|
||||
const { oldPassword, newPassword } = body;
|
||||
@@ -23,7 +25,7 @@ export default defineEventHandler(async (event) => {
|
||||
userDB.prepare('UPDATE user SET password = ? WHERE id = ?').run(hashedPassword, userId);
|
||||
|
||||
// 生成新的 JWT
|
||||
const token = createToken(userId);
|
||||
const token = createToken({ userId, password: user.password, username: user.username });
|
||||
|
||||
userDB.close();
|
||||
|
||||
|
||||
Reference in new issue
Block a user