Skip to content

Commit 9952809

Browse files
committed
feat(signup): hide email signup when email delivery is disabled (IdP-only)
1 parent fffabfa commit 9952809

3 files changed

Lines changed: 56 additions & 2 deletions

File tree

app/resources/signup/signup-view.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export function resolveSignupView(
2525
idps: IdProvider[],
2626
emailDeliveryEnabled: boolean
2727
): SignupView {
28-
const allowEmailEntry = settings.disableLoginWithEmail !== true;
28+
// Email-based signup (entry + link) needs email delivery to complete verification.
29+
// When delivery is off, hide the whole email path so signup is IdP-only.
30+
const allowEmailEntry = settings.disableLoginWithEmail !== true && emailDeliveryEnabled;
2931
return {
3032
showIdpButtons: settings.allowExternalIdp && idps.length > 0,
3133
allowEmailEntry,

cypress/component/resources/signup/signup-view.cy.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,48 @@ describe('resolveSignupView', () => {
4040
)
4141
).to.deep.equal({
4242
showIdpButtons: false,
43-
allowEmailEntry: true,
43+
allowEmailEntry: false,
4444
showEmailLink: false,
4545
showPasskey: false,
4646
showPassword: true,
4747
registrationDisabled: true,
4848
});
4949
});
50+
51+
it('hides email entry and link when emailDeliveryEnabled=false, regardless of Zitadel policy', () => {
52+
// RED→GREEN: before the fix allowEmailEntry was true when delivery was off.
53+
// With delivery off the whole email path must hide so signup is IdP-only.
54+
expect(resolveSignupView(base, idps, false)).to.deep.equal({
55+
showIdpButtons: true,
56+
allowEmailEntry: false,
57+
showEmailLink: false,
58+
showPasskey: true,
59+
showPassword: false,
60+
registrationDisabled: false,
61+
});
62+
});
63+
64+
it('keeps allowEmailEntry when Zitadel policy allows email AND delivery is on', () => {
65+
expect(resolveSignupView(base, idps, true)).to.deep.equal({
66+
showIdpButtons: true,
67+
allowEmailEntry: true,
68+
showEmailLink: true,
69+
showPasskey: true,
70+
showPassword: false,
71+
registrationDisabled: false,
72+
});
73+
});
74+
75+
it('hides email entry when Zitadel disableLoginWithEmail=true even if delivery is on', () => {
76+
expect(
77+
resolveSignupView({ ...base, disableLoginWithEmail: true } as LoginSettings, idps, true)
78+
).to.deep.equal({
79+
showIdpButtons: true,
80+
allowEmailEntry: false,
81+
showEmailLink: false,
82+
showPasskey: true,
83+
showPassword: false,
84+
registrationDisabled: false,
85+
});
86+
});
5087
});

cypress/component/routes/signup/signup-render.cy.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,19 @@ describe('signup/index — render adoption', () => {
7070
cy.get('input[type="hidden"][name="organization"]').should('have.value', 'acme');
7171
});
7272
});
73+
74+
it('shows IdP button and hides Email entry button when emailDeliveryEnabled=false (IdP-only signup)', () => {
75+
// view.allowEmailEntry=false when delivery is off — the Email button must not appear.
76+
mountSignup(
77+
loaderData({
78+
view: {
79+
...BASE_VIEW,
80+
allowEmailEntry: false,
81+
showEmailLink: false,
82+
},
83+
})
84+
);
85+
cy.contains('Google', { timeout: 6000 }).should('exist');
86+
cy.contains('Email').should('not.exist');
87+
});
7388
});

0 commit comments

Comments
 (0)