This commit is contained in:
hatim 2023-05-18 20:50:10 +02:00
parent dc920d5e0c
commit 25fe0ac9d2
2 changed files with 13 additions and 1 deletions

View file

@ -58,7 +58,7 @@ export default class {
} }
async AuthApp(req: Types.AuthAppRequest): Promise<Types.AuthApp> { async AuthApp(req: Types.AuthAppRequest): Promise<Types.AuthApp> {
const app = await this.storage.applicationStorage.GetApplication(req.name) const app = await this.storage.applicationStorage.GetApplicationByName(req.name)
return { return {
app: { app: {
id: app.app_id, id: app.app_id,

View file

@ -22,6 +22,18 @@ export default class {
return repo.save(newApplication) return repo.save(newApplication)
} }
async GetApplicationByName(name: string, entityManager = this.DB) {
const found = await entityManager.getRepository(Application).findOne({
where: {
name
}
})
if (!found) {
throw new Error(`application ${name} not found`)
}
return found
}
async GetApplication(appId: string, entityManager = this.DB): Promise<Application> { async GetApplication(appId: string, entityManager = this.DB): Promise<Application> {
const found = await entityManager.getRepository(Application).findOne({ const found = await entityManager.getRepository(Application).findOne({
where: { where: {