Skip to content

Commit b38ae6f

Browse files
waleedlatif1claude
andcommitted
fix(admin): close OAuth domain bypass, fix stale errors, deduplicate icon
- Add databaseHooks.user.create.before to enforce BLOCKED_SIGNUP_DOMAINS at the model level, covering all signup vectors (email, OAuth, social) not just /sign-up paths - Call .reset() on each mutation before firing to clear stale error state from previous operations - Change Admin nav icon from ShieldCheck to Lock to avoid duplicate with Access Control tab Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 02ac5da commit b38ae6f

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

apps/sim/app/workspace/[workspaceId]/settings/components/admin/admin.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,13 @@ export function Admin() {
209209
<Button
210210
variant='active'
211211
className='h-[28px] px-[8px] text-[12px]'
212-
onClick={() =>
212+
onClick={() => {
213+
setUserRole.reset()
213214
setUserRole.mutate({
214215
userId: u.id,
215216
role: u.role === 'admin' ? 'user' : 'admin',
216217
})
217-
}
218+
}}
218219
disabled={pendingUserIds.has(u.id)}
219220
>
220221
{u.role === 'admin' ? 'Demote' : 'Promote'}
@@ -223,7 +224,10 @@ export function Admin() {
223224
<Button
224225
variant='active'
225226
className='h-[28px] px-[8px] text-[12px]'
226-
onClick={() => unbanUser.mutate({ userId: u.id })}
227+
onClick={() => {
228+
unbanUser.reset()
229+
unbanUser.mutate({ userId: u.id })
230+
}}
227231
disabled={pendingUserIds.has(u.id)}
228232
>
229233
Unban
@@ -240,6 +244,7 @@ export function Admin() {
240244
variant='primary'
241245
className='h-[28px] px-[8px] text-[12px]'
242246
onClick={() => {
247+
banUser.reset()
243248
banUser.mutate(
244249
{
245250
userId: u.id,

apps/sim/app/workspace/[workspaceId]/settings/navigation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
HexSimple,
66
Key,
77
KeySquare,
8+
Lock,
89
LogIn,
910
Mail,
1011
Send,
@@ -167,7 +168,7 @@ export const allNavigationItems: NavigationItem[] = [
167168
{
168169
id: 'admin',
169170
label: 'Admin',
170-
icon: ShieldCheck,
171+
icon: Lock,
171172
section: 'superuser',
172173
requiresAdminRole: true,
173174
},

apps/sim/lib/auth/auth.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ export const auth = betterAuth({
116116
databaseHooks: {
117117
user: {
118118
create: {
119+
before: async (user) => {
120+
if (blockedSignupDomains) {
121+
const emailDomain = user.email?.split('@')[1]?.toLowerCase()
122+
if (emailDomain && blockedSignupDomains.has(emailDomain)) {
123+
throw new Error('Sign-ups from this email domain are not allowed.')
124+
}
125+
}
126+
return { data: user }
127+
},
119128
after: async (user) => {
120129
logger.info('[databaseHooks.user.create.after] User created, initializing stats', {
121130
userId: user.id,

0 commit comments

Comments
 (0)