mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
fixes to user registration
This commit is contained in:
parent
3e6de98d10
commit
240d67fbfa
@ -27,7 +27,6 @@
|
||||
"busboy": "^1.6.0",
|
||||
"connect-mongo": "^4.6.0",
|
||||
"content-range": "^2.0.2",
|
||||
"dicebar_lib": "1.0.1",
|
||||
"dotenv": "^16.0.3",
|
||||
"infisical-node": "^1.2.1",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
|
@ -10,11 +10,17 @@ export default {
|
||||
select: ["username", "email", "password", "fullName"],
|
||||
}, async (req, res) => {
|
||||
const result = await createUser(req.selection).catch((err) => {
|
||||
return res.status(500).json({
|
||||
res.status(500).json({
|
||||
message: `Error creating user > ${err.message}`,
|
||||
})
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
if (!result) {
|
||||
return false
|
||||
}
|
||||
|
||||
return res.json(result)
|
||||
})
|
||||
}
|
@ -1,10 +1,17 @@
|
||||
import { User } from "@shared-classes/DbModels"
|
||||
import Avatars from "dicebar_lib"
|
||||
import bcrypt from "bcrypt"
|
||||
|
||||
export default async function (payload) {
|
||||
let { username, password, email, fullName, roles, avatar } = payload
|
||||
|
||||
if (username.length < 3) {
|
||||
throw new Error("Username must be at least 3 characters")
|
||||
}
|
||||
|
||||
if (username.length > 64) {
|
||||
throw new Error("Username cannot be longer than 64 characters")
|
||||
}
|
||||
|
||||
// if username has capital letters, throw error
|
||||
if (username !== username.toLowerCase()) {
|
||||
throw new Error("Username must be lowercase")
|
||||
@ -43,7 +50,7 @@ export default async function (payload) {
|
||||
password: hash,
|
||||
email: email,
|
||||
fullName: fullName,
|
||||
avatar: avatar ?? Avatars.generate({ seed: username, type: "initials" }).uri,
|
||||
avatar: avatar ?? `https://api.dicebear.com/7.x/thumbs/svg?seed=${username}`,
|
||||
roles: roles,
|
||||
createdAt: new Date().getTime(),
|
||||
})
|
||||
|
@ -1,4 +1,4 @@
|
||||
global.FORCE_ENV = "prod"
|
||||
global.FORCE_ENV = "dev"
|
||||
|
||||
import Boot from "linebridge/bootstrap"
|
||||
import { Server } from "linebridge/dist/server"
|
||||
|
Loading…
x
Reference in New Issue
Block a user