UNPKG

keystone-6-oauth

Version:

Keystone6 Plugin that enables social logins such as Google, Twitter, Github, Facebook and others.

24 lines (22 loc) 599 B
import { AuthTokenRequestErrorCode } from '../types'; export async function findMatchingIdentity( identityField: string, identity: string | number, queryAPI: any ): Promise< | { success: false; code: AuthTokenRequestErrorCode } | { success: true; item: any } > { const item = await queryAPI.findOne({ where: { [identityField]: identity }, }); // Identity failures with helpful errors let code: AuthTokenRequestErrorCode | undefined; if (!item) { code = 'IDENTITY_NOT_FOUND'; } if (code) { return { success: false, code }; } return { success: true, item }; }