add accountCreated

This commit is contained in:
lingdocs 2022-08-26 23:16:21 +04:00
parent 9528624f95
commit 928e283b3c
4 changed files with 12 additions and 2 deletions

View File

@ -106,6 +106,7 @@ export async function createNewUser(input: {
password,
level: "basic",
tests: [],
accountCreated: now,
lastLogin: now,
lastActive: now,
userTextOptionsRecord: undefined,
@ -124,6 +125,7 @@ export async function createNewUser(input: {
[input.strategy]: input.profile,
level: "basic",
tests: [],
accountCreated: now,
lastLogin: now,
lastActive: now,
userTextOptionsRecord: undefined,
@ -146,6 +148,7 @@ export async function createNewUser(input: {
lastLogin: now,
tests: [],
lastActive: now,
accountCreated: now,
level: "basic",
userTextOptionsRecord: undefined,
}
@ -163,6 +166,7 @@ export async function createNewUser(input: {
lastLogin: now,
tests: [],
lastActive: now,
accountCreated: now,
level: "basic",
userTextOptionsRecord: undefined,
}

View File

@ -151,7 +151,9 @@ const authRouter = (passport: PassportStatic) => {
if (!req.user || !req.user.admin) {
return res.redirect("/");
}
const users = await getAllLingdocsUsers();
const users = (await getAllLingdocsUsers()).sort((a, b) => (
(a.accountCreated || 0) - (b.accountCreated || 0)
));
res.render("admin", { users });
} catch (e) {
next(e);

View File

@ -34,7 +34,7 @@
<th scope="col">Email</th>
<th scope="col">Providers</th>
<th scope="col">Level</th>
<th scope="col">Tests</th>
<th scope="col">Joined</th>
<th shope="col"></th>
</tr>
</thead>
@ -88,6 +88,9 @@
<%= users[i].level %>
<% } %>
</td>
<td>
<%= users[i].accountCreated %>
</td>
<td>
<button class="btn btn-sm btn-danger" onClick="handleDeleteUser('<%= users[i].userId %>', '<%= users[i].name %>')"><i class="fa fa-trash"></i></button>
</td>

View File

@ -47,6 +47,7 @@ export type LingdocsUser = {
},
upgradeToStudentRequest?: "waiting" | "denied",
tests: TestResult[],
accountCreated?: TimeStamp,
lastLogin: TimeStamp,
lastActive: TimeStamp,
userTextOptionsRecord: undefined | UserTextOptionsRecord,