We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f53fb0e commit e9bb91aCopy full SHA for e9bb91a
1 file changed
app/api/v1/auth/signup/route.ts
@@ -21,11 +21,26 @@ export async function POST(request: Request) {
21
});
22
}
23
24
+ // using localpart of email as fallback
25
+ let newName;
26
+ if (name === "" || !name && typeof email === "string") {
27
+ const localPart = email.split("@")[0];
28
+ // a little transformation can't be missing
29
+ newName = localPart
30
+ .replace(/[._-]+/g, ' ')
31
+ .trim()
32
+ .split(' ')
33
+ .map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()) // capitalize
34
+ .join(' ');
35
+ } else {
36
+ newName = name;
37
+ }
38
+
39
const pb = getServerPB();
40
41
// 1. Create the user
42
const user = await pb.collection('users').create({
- name,
43
+ newName,
44
email,
45
password,
46
passwordConfirm,
0 commit comments