Compare commits
No commits in common. "5c67fb517921060fe3cc0afa887ecd6521ad27ae" and "642cd67678ace46e9f34662d4a66b358de9a8701" have entirely different histories.
5c67fb5179
...
642cd67678
|
@ -217,7 +217,7 @@ server {
|
|||
When a user upgrades their account level to `student` or `editor`:
|
||||
|
||||
1. A doc in the `_users` db is created with their Firebase Authentication info, account level, and a password they can use for syncing their personal wordlistdb
|
||||
2. A user database is created which they use to sync their personal wordlist.
|
||||
2. A user database is created (automatically by `couchdb_peruser`) which they use to sync their personal wordlist.
|
||||
|
||||
There is also a `review-tasks` database which is used to store all the review tasks for editors and syncs with the review tasks in the app for the editor(s).
|
||||
|
||||
|
|
|
@ -7,12 +7,9 @@ import { DocumentInsertResponse } from "nano";
|
|||
import env from "./src/lib/env-vars";
|
||||
import * as T from "../website/src/types/account-types";
|
||||
import {
|
||||
addCouchDbAuthUser,
|
||||
generateWordlistDbPassword,
|
||||
getAllLingdocsUsers,
|
||||
getLingdocsUser,
|
||||
insertLingdocsUser,
|
||||
updateLingdocsUser,
|
||||
} from "./src/lib/couch-db";
|
||||
|
||||
const nano = Nano(env.couchDbURL);
|
||||
|
@ -34,6 +31,7 @@ function processAPIResponse(
|
|||
async function main() {
|
||||
const users = await getAllLingdocsUsers();
|
||||
const usersWDbs = users.filter((x) => x.level !== "basic");
|
||||
const paidUsersEmails: string[] = [];
|
||||
for (let user of usersWDbs) {
|
||||
// if (!user.docs.length) return;
|
||||
// const u = user.docs[0];
|
||||
|
@ -41,22 +39,6 @@ async function main() {
|
|||
if (user.level === "basic") {
|
||||
throw new Error("");
|
||||
}
|
||||
process.stdout.write(
|
||||
`Checking for _user for ${user.name} - ${user.email}...`
|
||||
);
|
||||
const uzrs = nano.db.use("_users");
|
||||
const r = await uzrs.find({
|
||||
selector: { _id: `org.couchdb.user:${user.userId}` },
|
||||
});
|
||||
console.log(r.docs.length ? "✅" : "❌");
|
||||
if (!r.docs.length) {
|
||||
console.log(`Creating wordlist db for ${user.name} - ${user.email}...`);
|
||||
const { password, userDbName } = await addCouchDbAuthUser(user.userId);
|
||||
await updateLingdocsUser(user.userId, {
|
||||
couchDbPassword: password,
|
||||
wordlistDbName: userDbName,
|
||||
});
|
||||
}
|
||||
process.stdout.write(`Checking for db for ${user.name} - ${user.email}...`);
|
||||
const userDb = nano.db.use(user.wordlistDbName);
|
||||
try {
|
||||
|
@ -107,6 +89,16 @@ async function main() {
|
|||
return "done";
|
||||
}
|
||||
|
||||
// function removeRedundant(tests: T.TestResult[]): T.TestResult[] {
|
||||
// if (tests.length === 0) return tests;
|
||||
// const first = tests[0];
|
||||
// const rest = tests.slice(1);
|
||||
// const redundancies = rest.filter(x => ((x.id === first.id)) && (x.done === first.done));
|
||||
// return redundancies.length < 2
|
||||
// ? [first, ...removeRedundant(rest)]
|
||||
// : removeRedundant(rest);
|
||||
// }
|
||||
|
||||
main().then((res) => {
|
||||
console.log(res);
|
||||
});
|
|
@ -146,7 +146,6 @@ export async function updateLingdocsUser(
|
|||
| { upgradeToStudentRequest: "waiting" }
|
||||
| { upgradeToStudentRequest: "denied" }
|
||||
| { tests: T.TestResult[] }
|
||||
| { wordlistDbName: T.WordlistDbName; couchDbPassword: T.UserDbPassword }
|
||||
): Promise<T.LingdocsUser> {
|
||||
const user = await getLingdocsUser("userId", uuid);
|
||||
if (!user) throw new Error("unable to update - user not found " + uuid);
|
||||
|
@ -239,7 +238,7 @@ export function getWordlistDbName(uid: T.UUID): T.WordlistDbName {
|
|||
return `${userDbPrefix}${stringToHex(uid)}` as T.WordlistDbName;
|
||||
}
|
||||
|
||||
export function generateWordlistDbPassword(): T.UserDbPassword {
|
||||
function generateWordlistDbPassword(): T.UserDbPassword {
|
||||
function makeChunk(): string {
|
||||
return Math.random().toString(36).slice(2);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<h1 class="h3 mb-4 fw-normal">Sign in to LingDocs</h1>
|
||||
<!-- <p class="small mb-2">New? Enter an e-mail and password to sign up</p> -->
|
||||
<div class="form-floating mt-3">
|
||||
<input type="email" pattern='(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])' required class="form-control" id="emailInput" placeholder="name@example.com">
|
||||
<input type="email" required class="form-control" id="emailInput" placeholder="name@example.com">
|
||||
<label for="floatingInput">Email address</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
|
@ -61,7 +61,7 @@
|
|||
<a href="/google" class="mt-1 w-100 btn btn-lg btn-secondary" role="button"><i class="fab fa-google mr-2"></i> Sign In With Google</a>
|
||||
<a href="/twitter" class="mt-3 w-100 btn btn-lg btn-secondary" role="button"><i class="fab fa-twitter mr-2"></i> Sign In With Twitter</a>
|
||||
<a href="/github" class="mt-3 w-100 btn btn-lg btn-secondary" role="button"><i class="fab fa-github mr-2"></i> Sign In With GitHub</a>
|
||||
<p class="mt-5 text-muted">© <script type="text/javascript">document.write(new Date().getFullYear());</script><noscript>2023</noscript> <a href="https://www.lingdocs.com/">LingDocs.com</a></p>
|
||||
<p class="mt-5 text-muted">© 2021 <a href="https://www.lingdocs.com/">LingDocs.com</a></p>
|
||||
<p class="mt-3 text-muted small"><a href="/privacy">privacy policy</a></p>
|
||||
</main>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue