Commit 4e8888f9 authored by “Yevgeniy's avatar “Yevgeniy

#163 router users changed

parent 1882dab8
...@@ -15,7 +15,6 @@ const dataSource = myDataSource; ...@@ -15,7 +15,6 @@ const dataSource = myDataSource;
router.post ('/', async (req:Request, res:Response):Promise<void |Response>=>{ router.post ('/', async (req:Request, res:Response):Promise<void |Response>=>{
try{ try{
const {email} = req.body const {email} = req.body
console.log("emeil", email)
const user = await dataSource const user = await dataSource
.getRepository(User) .getRepository(User)
.findOne({ .findOne({
...@@ -23,14 +22,12 @@ router.post ('/', async (req:Request, res:Response):Promise<void |Response>=>{ ...@@ -23,14 +22,12 @@ router.post ('/', async (req:Request, res:Response):Promise<void |Response>=>{
email:email email:email
} }
}) })
console.log('user ', user)
if (!user) return res.status(404).send({message:'user not found'}) if (!user) return res.status(404).send({message:'user not found'})
const token = nanoid(); const token = nanoid();
const passwordRecovery = new PasswordRecovery() const passwordRecovery = new PasswordRecovery()
passwordRecovery.user= user; passwordRecovery.user= user;
passwordRecovery.token=token; passwordRecovery.token=token;
await passwordRecovery.save() await passwordRecovery.save()
console.log('passwordRecover ' , passwordRecovery)
const url = `${frontend_url}/reset-password/${token}`; const url = `${frontend_url}/reset-password/${token}`;
await transporter.sendMail({ await transporter.sendMail({
from:"planner45@yandex.com", from:"planner45@yandex.com",
......
...@@ -78,24 +78,6 @@ router.get('/all-fields/', async (req : Request, res : Response):Promise<object> ...@@ -78,24 +78,6 @@ router.get('/all-fields/', async (req : Request, res : Response):Promise<object>
}) })
//** return displayName of user, requested by userId */
router.get('/display-name/:userId',auth, async (req : Request, res : Response):Promise<object> => {
try{
const {userId} =req.params
const displayName = await dataSource
.createQueryBuilder()
.select(['user.displayName'])
.from(User, "user")
.where("user.id = :userId", { userId })
.getOne()
if (!displayName) return res.status(404).send({message:'displayName not found'})
return res.send({displayName})
} catch(e) {
return res.status(502).send({message:(e as Error).message})
}
})
/**create new user*/ /**create new user*/
router.post('/', upload.single("avatar"), async (req : Request, res : Response):Promise<object> => { router.post('/', upload.single("avatar"), async (req : Request, res : Response):Promise<object> => {
try{ try{
......
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