import { bold } from 'chalk' ; import doSamlLogin from './saml' ; import showLoginPrompt from './prompt' ; import { LoginResult , SAMLError } from './types' ; import confirm from '../input/confirm' ; import Client from '../client' ; export default async function reauthenticate ( client , error ) { if ( error . teamId && error . enforced ) { client . output . log ( `You must re-authenticate with SAML to use ${ bold ( error . scope ) } scope.` ) ; if ( await confirm ( `Log in with SAML?` , true ) ) { return doSamlLogin ( client , error . teamId ) ; } } else { client . output . log ( `You must re-authenticate to use ${ bold ( error . scope ) } scope.` ) ; return showLoginPrompt ( client , error ) ; } return 1 ; }