slight refactor

This commit is contained in:
lingdocs 2021-08-23 09:12:35 +04:00
parent 6892f7d90a
commit 72a9959903
4 changed files with 4 additions and 4 deletions

View File

@ -93,7 +93,7 @@ export async function updateLingdocsUser(uuid: T.UUID, toUpdate:
{ {
level: "student", level: "student",
wordlistDbName: T.WordlistDbName, wordlistDbName: T.WordlistDbName,
userDbPassword: T.UserDbPassword, couchDbPassword: T.UserDbPassword,
} }
): Promise<T.LingdocsUser> { ): Promise<T.LingdocsUser> {
const user = await getLingdocsUser("userId", uuid); const user = await getLingdocsUser("userId", uuid);

View File

@ -123,7 +123,7 @@ apiRouter.put("/user/upgrade", async (req, res, next) => {
// // create user db // // create user db
// const { name } = await createWordlistDatabase(userId, password); // const { name } = await createWordlistDatabase(userId, password);
// update LingdocsUser // update LingdocsUser
const u = await updateLingdocsUser(userId, { level: "student", wordlistDbName: userDbName, userDbPassword: password }); const u = await updateLingdocsUser(userId, { level: "student", wordlistDbName: userDbName, couchDbPassword: password });
const upgraded: T.UpgradeUserResponse = { const upgraded: T.UpgradeUserResponse = {
ok: true, ok: true,
message: "user upgraded to student", message: "user upgraded to student",

View File

@ -38,7 +38,7 @@ export type LingdocsUser = {
{ level: "basic"} | { level: "basic"} |
{ {
level: "student" | "editor", level: "student" | "editor",
userDbPassword: UserDbPassword, couchDbPassword: UserDbPassword,
wordlistDbName: WordlistDbName, wordlistDbName: WordlistDbName,
} }
) & import("nano").MaybeDocument; ) & import("nano").MaybeDocument;

View File

@ -79,7 +79,7 @@ function initializeLocalDb(type: LocalDbType, refresh: () => void, user: AT.Ling
: (type === "wordlist" && "wordlistDbName" in user) : (type === "wordlist" && "wordlistDbName" in user)
? user.wordlistDbName ? user.wordlistDbName
: ""; : "";
const password = "userDbPassword" in user ? user.userDbPassword : ""; const password = "couchDbPassword" in user ? user.couchDbPassword : "";
const db = dbs[type]; const db = dbs[type];
// only initialize the db if it doesn't exist or if it has a different name // only initialize the db if it doesn't exist or if it has a different name
if ((!db) || (db.db?.name !== name)) { if ((!db) || (db.db?.name !== name)) {