mirror of
https://github.com/logto-io/logto.git
synced 2025-04-07 23:01:25 -05:00
feat(core): add sign-in-settings api for client use (#534)
add sample sign-in-settigns api for client use
This commit is contained in:
parent
3718a18286
commit
85c9eabfca
2 changed files with 25 additions and 0 deletions
packages/core/src/routes
|
@ -49,6 +49,10 @@ jest.mock('@/queries/sign-in-experience', () => ({
|
|||
const signInExperienceRequester = createRequester({ authedRoutes: signInExperiencesRoutes });
|
||||
|
||||
describe('GET /sign-in-exp', () => {
|
||||
afterAll(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should call findDefaultSignInExperience', async () => {
|
||||
const response = await signInExperienceRequester.get('/sign-in-exp');
|
||||
expect(findDefaultSignInExperience).toHaveBeenCalledTimes(1);
|
||||
|
@ -74,6 +78,19 @@ describe('GET /sign-in-exp', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('GET /sign-in-settings', () => {
|
||||
afterAll(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should call findDefaultSignInExperience', async () => {
|
||||
const response = await signInExperienceRequester.get('/sign-in-settings');
|
||||
expect(findDefaultSignInExperience).toHaveBeenCalledTimes(1);
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.body).toEqual(mockSignInExperience);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PATCH /sign-in-exp', () => {
|
||||
it('should not update social connector ids when social sign-in is disabled', async () => {
|
||||
const signInMethods = { ...mockSignInMethods, social: SignInMethodState.disabled };
|
||||
|
|
|
@ -41,6 +41,14 @@ export default function signInExperiencesRoutes<T extends AuthedRouter>(router:
|
|||
return next();
|
||||
});
|
||||
|
||||
router.get('/sign-in-settings', async (ctx, next) => {
|
||||
// TODO: Social Connector Details
|
||||
const signInExperience = await findDefaultSignInExperience();
|
||||
ctx.body = signInExperience;
|
||||
|
||||
return next();
|
||||
});
|
||||
|
||||
router.patch(
|
||||
'/sign-in-exp',
|
||||
koaGuard({
|
||||
|
|
Loading…
Add table
Reference in a new issue