-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated middleware function in separate file
1 parent
c9e9873
commit 66cd546
Showing
11 changed files
with
105 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
exports.ConvertChosenTime = (str) => { | ||
const date0 = new Date(str); | ||
date0.setHours(date0.getHours() + 5.5); | ||
date0.setMinutes(date0.getMinutes() + 30); | ||
let hour = date0.getHours(); | ||
const minutes = date0.getMinutes(); | ||
let end = 'AM'; | ||
if (hour >= 12) { | ||
hour -= 12; | ||
end = 'PM'; | ||
} | ||
const JoinedTime = [hour, minutes].join(':'); | ||
return `${JoinedTime} ${end}`; | ||
}; | ||
|
||
exports.convert = (str) => { | ||
const date0 = new Date(str); | ||
date0.setHours(date0.getHours() + 5); | ||
date0.setMinutes(date0.getMinutes() + 30); | ||
const mnth = `0${date0.getMonth() + 1}`.slice(-2); | ||
const day = `0${date0.getDate()}`.slice(-2); | ||
return [day, mnth, date0.getFullYear()].join('-'); | ||
}; | ||
|
||
exports.isLoggedIn = (req, res, next) => { | ||
if (req.isAuthenticated()) { | ||
return next(); | ||
} | ||
|
||
return res.redirect('back'); | ||
}; | ||
|
||
exports.isAuthorizedAmbulance = (req, res, next) => { | ||
if ( | ||
req.isAuthenticated() && | ||
req.params.ambulanceid.toString() === req.user._id.toString() | ||
) { | ||
return next(); | ||
} | ||
|
||
return res.redirect('back'); | ||
}; | ||
|
||
exports.isAuthorizedDoctor = (req, res, next) => { | ||
if ( | ||
req.isAuthenticated() && | ||
req.params.doctorid.toString() === req.user._id.toString() | ||
) { | ||
return next(); | ||
} | ||
|
||
return res.redirect('back'); | ||
}; | ||
|
||
exports.isAuthorizedPatient = (req, res, next) => { | ||
if ( | ||
req.isAuthenticated() && | ||
req.params.patientid.toString() === req.user._id.toString() | ||
) { | ||
return next(); | ||
} | ||
|
||
return res.redirect('back'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters