diff --git a/backend/src/klicktipp.ts b/backend/src/klicktipp.ts new file mode 100644 index 000000000..3139cd296 --- /dev/null +++ b/backend/src/klicktipp.ts @@ -0,0 +1,28 @@ +import connection from '@/typeorm/connection' +import { getKlickTippUser } from './apis/KlicktippController' +import { User } from '../../database/entity/User' +import { getConnection } from '@dbTools/typeorm' + +export async function retrieveNotRegisteredEmails(): Promise { + const con = await connection() + if (!con) { + throw new Error('No connection to database') + } + const users = await User.find() + const notRegisteredUser = [] + for (let i = 0; i < users.length; i++) { + const user = users[i] + try { + await getKlickTippUser(user.email) + } catch (err) { + notRegisteredUser.push(user.email) + // eslint-disable-next-line no-console + console.log(`${user.email}`) + } + } + await con.close() + console.log('User die nicht bei KlickTipp vorhanden sind: ', notRegisteredUser) + return notRegisteredUser +} + +retrieveNotRegisteredEmails()