import getPool from "@cocalc/database/pool" ; import { capitalize } from "@cocalc/util/misc" ; interface Strategy { name : string ; display : string ; icon : string ; backgroundColor : string ; } export default async function getStrategies ( ) { const pool = getPool ( "long" ) ; const { rows } = await pool . query ( "SELECT strategy, conf#>>'{icon}' as icon, conf#>>'{display}' as display FROM passport_settings WHERE strategy != 'site_conf'" ) ; const strategies = [ ] ; for ( const row of rows ) { strategies . push ( { name : row . strategy , display : row . display ?? ( row . strategy == "github" ? "GitHub" : capitalize ( row . strategy ) ) , icon : row . icon ?? row . strategy , backgroundColor : COLORS [ row . strategy ] ?? "" , } ) ; } return strategies ; } const COLORS = { github : "#000000" , facebook : "#428bca" , google : "#dc4857" , twitter : "#55acee" , } ;