) {
// console.log('------------', user)
try {
return await prisma.user.create({
data: user
})
// const existingUser = await existUser(user);
// // console.log('[LOG]', existingUser, user, '=======')
// if (!existingUser) {
//
// } else {
// // console.log('user==========', existingUser)
// return existingUser;
// }
} catch (e) {
throw new Error("用户创建失败");
// return false;
}
}
function cleanUpString(input: string): string {
try {
// 去除前后空格
let cleanedString = input.trim();
// 去除非中文、英文、@和.字符
cleanedString = cleanedString.replace(/[^\u4e00-\u9fa5a-zA-Z@.]/g, '');
return cleanedString;
}
catch {
return '';
}
}
function cleanPassword(input: string): string {
try {
// 去除前后空格
return input.trim()
}
catch {
return '';
}
}
/**
* Email HTML body
* Insert invisible space into domains from being turned into a hyperlink by email
* clients like Outlook and Apple mail, as this is confusing because it seems
* like they are supposed to click on it to sign in.
*
* @note We don't add the email address to avoid needing to escape it, if you do, remember to sanitize it!
*/
function email_text(params: { url: string, token: number|string, host: string}) {
const { url, token, host } = params;
return `Sign in to ${host}\n\nYour sign-in code is: ${token}\n\nOr click on this link to sign in:\n${url}\n\n`;
}
function email_html(params: { url: string, token: number|string, host: string, theme: Theme }) {
const { url, token, host, theme } = params
const escapedHost = host.replace(/\./g, ".")
const escapedUrl = url.replace(/\./g, ".")
// const brandColor = theme.brandColor || "#346df1"
// const color = {
// background: "#f9f9f9",
// text: "#444",
// mainBackground: "#fff",
// buttonBackground: brandColor,
// buttonBorder: brandColor,
// buttonText: theme.buttonText || "#fff",
// }
return `Sign in to ${escapedHost}
Your sign-in code is: ${token}
Or click on this link to sign in:
${escapedUrl}
If you did not request this email, you can safely ignore it.
`;
}