#136 added projects creation on the moment of user creation

parent 8d19d7f9
...@@ -93,15 +93,26 @@ router.post('/', upload.single("avatar"), async (req : Request, res : Response): ...@@ -93,15 +93,26 @@ router.post('/', upload.single("avatar"), async (req : Request, res : Response):
user.role = role; user.role = role;
user.generateToken(); user.generateToken();
await user.save(); await user.save();
/**Создание проектов "Личные дела" и "Не определено"
* у только что созданого пользователя*/
const newProject = new Project(); const newProject = new Project();
newProject.title = 'Личные дела'; newProject.title = 'Личные дела';
newProject.color= 'Green'; newProject.color= '#f595ee';
await newProject.save() await newProject.save()
const newMember = new Member(); const newMember = new Member();
newMember.user = user; newMember.user = user;
newMember.project = newProject; newMember.project = newProject;
newMember.roleProject = MemberRole.ADMIN; newMember.roleProject = MemberRole.ADMIN;
await newMember.save(); await newMember.save();
const notDefinedTaskProject = new Project();
notDefinedTaskProject.title = 'Не определено';
notDefinedTaskProject.color= '#03fcfc';
await notDefinedTaskProject.save()
const notDefinedTaskProjectMember = new Member();
notDefinedTaskProjectMember.user = user;
notDefinedTaskProjectMember.project = notDefinedTaskProject;
notDefinedTaskProjectMember.roleProject = MemberRole.ADMIN;
await notDefinedTaskProjectMember.save();
const userToFront:User|null = await dataSource.manager.findOneBy(User, { const userToFront:User|null = await dataSource.manager.findOneBy(User, {
email: user.email email: user.email
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment