0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): adding social connector should mark related get-started action item as completed (#3693)

* fix(console): adding social connector should mark related get-started action item as completed

* chore: add changeset
This commit is contained in:
Charles Zhao 2023-04-15 08:10:42 +08:00 committed by GitHub
parent c5eb3a2ba7
commit 457cb28224
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 3 deletions

View file

@ -0,0 +1,6 @@
---
"@logto/console": patch
"@logto/schemas": patch
---
Adding social connectors will now mark the related get-started action item as completed.

View file

@ -125,9 +125,7 @@ function Guide({ connector, onClose }: Props) {
})
.json<ConnectorResponse>();
await updateConfigs({
...conditional(!isSocialConnector && { passwordlessConfigured: true }),
});
await updateConfigs({ passwordlessConfigured: true });
onClose();
toast.success(t('general.saved'));

View file

@ -0,0 +1,32 @@
import { sql } from 'slonik';
import type { AlterationScript } from '../lib/types/alteration.js';
const adminConsoleConfigKey = 'adminConsole';
const alteration: AlterationScript = {
up: async (pool) => {
const tenantIds = await pool.many<{ id: string }>(sql`select id from tenants`);
await Promise.all(
tenantIds.map(async ({ id }) => {
const { count } = await pool.one<{ count: number }>(sql`
select count(*) from connectors
where tenant_id = ${id} and connector_id <> 'logto-sms' and connector_id <> 'logto-email' and connector_id <> 'logto-social-demo';
`);
if (count > 0) {
await pool.query(sql`
update logto_configs set value = jsonb_set(value, '{passwordlessConfigured}', 'true')
where tenant_id = ${id} and key = ${adminConsoleConfigKey};
`);
}
})
);
},
down: async () => {
// Do nothing as there is no alteration made to the DB schemas, only fixing data.
},
};
export default alteration;