mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-03-06 20:17:32 +08:00
feat: add register page and logout button
This commit is contained in:
@@ -54,6 +54,8 @@ export interface IStorage {
|
||||
// 用户相关
|
||||
registerUser(userName: string, password: string): Promise<void>;
|
||||
verifyUser(userName: string, password: string): Promise<boolean>;
|
||||
// 检查用户是否存在(无需密码)
|
||||
checkUserExist(userName: string): Promise<boolean>;
|
||||
|
||||
// 搜索历史相关
|
||||
getSearchHistory(): Promise<string[]>;
|
||||
@@ -171,6 +173,13 @@ class RedisStorage implements IStorage {
|
||||
return stored === password;
|
||||
}
|
||||
|
||||
// 检查用户是否存在
|
||||
async checkUserExist(userName: string): Promise<boolean> {
|
||||
// 使用 EXISTS 判断 key 是否存在
|
||||
const exists = await this.client.exists(this.userPwdKey(userName));
|
||||
return exists === 1;
|
||||
}
|
||||
|
||||
// ---------- 搜索历史 ----------
|
||||
private shKey = 'moontv:search_history';
|
||||
|
||||
@@ -342,6 +351,11 @@ export class DbManager {
|
||||
return this.storage.verifyUser(userName, password);
|
||||
}
|
||||
|
||||
// 检查用户是否已存在
|
||||
async checkUserExist(userName: string): Promise<boolean> {
|
||||
return this.storage.checkUserExist(userName);
|
||||
}
|
||||
|
||||
// ---------- 搜索历史 ----------
|
||||
async getSearchHistory(): Promise<string[]> {
|
||||
return this.storage.getSearchHistory();
|
||||
|
||||
Reference in New Issue
Block a user