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

Commit

Permalink
intrn(manager): make method to find resetter emails
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Nov 23, 2022
1 parent bdca344 commit 8b61b63
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
23 changes: 23 additions & 0 deletions database/managers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import type {
import Log from "$!/singletons/log"
import deserialize from "$/object/deserialize"
import runThroughPipeline from "$/helpers/run_through_pipeline"
import { RESET_PASSWORD } from "$/permissions/user_combinations"
import convertTimeToMinutes from "$/time/convert_time_to_minutes"
import { user as permissionGroup } from "$/permissions/permission_list"

import Role from "%/models/role"
import Model from "%/models/user"
Expand Down Expand Up @@ -293,6 +295,27 @@ export default class UserManager extends BaseManager<Model, RawUser, UserQueryPa
return []
}

async retrieveResetterEmails(): Promise<Serializable> {
try {
const { rows, count } = await Model.findAndCountAll({
"include": [
{
"model": Role,
"required": true,
"where": new Condition().greaterThanOrEqual(
"userFlags", permissionGroup.generateMask(...RESET_PASSWORD)
).build()
}
],
...this.transaction.transactionObject
})

return await this.serialize(rows)
} catch (error) {
throw this.makeBaseError(error)
}
}

private async createStudents(
incompleteProfiles: ProcessedDataForStudent[],
departmentModels: { [key:string]: Department },
Expand Down
4 changes: 1 addition & 3 deletions shareable/permissions/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import type {
PermissionMap,
PermissionInfo,
LevelPermission,
OperationPermission
} from "$/types/permission"
OperationPermission,

import {
VIEW,
CREATE,
UPDATE,
Expand Down

0 comments on commit 8b61b63

Please sign in to comment.