Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
refactor: use username to retrieve member's loans
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwigoric committed Oct 31, 2023
1 parent 688a005 commit 66a6d53
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/routes/loan-applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import Loanee from '../models/loanee.js'
*
* Get all loan applications of a loanee
*/
router.get('/:loaneeId', async (req, res, next) => {
router.get('/:username', async (req, res, next) => {
passport.authenticate('is-manager', { session: false }, async (err, manager, info) => {
if (err) return next(err)
if (!manager) return res.status(401).json(info)

const loaneeId = req.params.loaneeId
const { username } = req.params

// Get loanee by UUID
const loanee = await Loanee.findOne({ uuid: loaneeId }).lean()
const loanee = await Loanee.findOne({ username }).lean()

const loans = await LoanApplication.find({ loanee: loanee._id }).populate('loanee').lean()

Expand Down

0 comments on commit 66a6d53

Please sign in to comment.