mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-19 23:53:17 -05:00
fix: prevent undefined from passed to adapter in username plugin (#4361)
This commit is contained in:
@@ -409,7 +409,9 @@ export const createAdapter =
|
||||
});
|
||||
}
|
||||
|
||||
transformedData[newFieldName] = newValue;
|
||||
if (newValue !== undefined) {
|
||||
transformedData[newFieldName] = newValue;
|
||||
}
|
||||
}
|
||||
return transformedData;
|
||||
};
|
||||
|
||||
@@ -488,8 +488,12 @@ export const username = (options?: UsernameOptions) => {
|
||||
);
|
||||
},
|
||||
handler: createAuthMiddleware(async (ctx) => {
|
||||
ctx.body.displayUsername ||= ctx.body.username;
|
||||
ctx.body.username ||= ctx.body.displayUsername;
|
||||
if (ctx.body.username && !ctx.body.displayUsername) {
|
||||
ctx.body.displayUsername = ctx.body.username;
|
||||
}
|
||||
if (ctx.body.displayUsername && !ctx.body.username) {
|
||||
ctx.body.username = ctx.body.displayUsername;
|
||||
}
|
||||
}),
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user