Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(user): pass admin emails to as page prop
Browse files Browse the repository at this point in the history
* first  3 emails will be extracted
  • Loading branch information
lemredd committed Nov 22, 2022
1 parent c0479b1 commit 7a4756e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions routes/enhancer/user/log_in.get.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import type { Request } from "!/types/dependent"
import type { Serializable } from "$/types/general"
import type { DocumentProps } from "$/types/server"
import type { UserListDocument } from "$/types/documents/user"

import { DEFAULT_LIST_LIMIT } from "$/constants/numerical"

import Policy from "!/bases/policy"
import PageMiddleware from "!/bases/controller-likes/page_middleware"
import DynamicGatedRedirector from "!/middlewares/miscellaneous/dynamic_gated_redirector"

import Manager from "%/managers/user"

export default class extends PageMiddleware {
get filePath(): string { return __filename }

Expand All @@ -21,4 +27,31 @@ export default class extends PageMiddleware {
return Promise.resolve(null)
}) as unknown as Policy
}

async getPageProps(unusedRequest: Request): Promise<Serializable> {
const manager = new Manager()

const adminUsers = await manager.list({
"filter": {
"department": "*",
"existence": "exists",
"kind": "unreachable_employee",
"role": "*",
"slug": ""
},
"page": {
"limit": DEFAULT_LIST_LIMIT,
"offset": 0
},
"sort": [ "email" ]
}) as UserListDocument

const adminEmails = adminUsers.data
.map(user => user.attributes.email)
.slice(0, 3)

return {
adminEmails
}
}
}

0 comments on commit 7a4756e

Please sign in to comment.