Skip to content

Commit

Permalink
Updated auth route. (#296)
Browse files Browse the repository at this point in the history
Co-authored-by: weskubo-cgi <[email protected]>
  • Loading branch information
weskubo-cgi and weskubo-cgi authored Jul 19, 2024
1 parent ebe74b6 commit b9b7542
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
36 changes: 19 additions & 17 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"express": "^4.18.2",
"express-prometheus-middleware": "^0.8.5",
"express-session": "^1.17.1",
"express-validator": "^6.9.2",
"express-validator": "^7.1.0",
"fast-safe-stringify": "^2.0.7",
"form-data": "^4.0.0",
"has-ansi": "^4.0.0",
Expand Down
13 changes: 10 additions & 3 deletions backend/src/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ const express = require('express')
const auth = require('../components/auth')
const log = require('../components/logger')
const { v4: uuidv4 } = require('uuid')
const { getUserGuid, isIdirUser } = require('../components/utils')
const { getUserGuid } = require('../components/utils')

const { body, validationResult } = require('express-validator')
const { checkExact, checkSchema, validationResult } = require('express-validator')
const router = express.Router()

const refreshSchema = {
refreshToken: {
in: ['body'],
exists: { errorMessage: '[refreshToken] is required' },
},
}

router.get('/', (_req, res) => {
res.status(200).json({
endpoints: ['/callback', '/callback_idir', '/login', '/logout', '/refresh', '/token'],
Expand Down Expand Up @@ -80,7 +87,7 @@ const UnauthorizedRsp = {
}

//refreshes jwt on refresh if refreshToken is valid
router.post('/refresh', [body('refreshToken').exists()], async (req, res) => {
router.post('/refresh', checkExact(checkSchema(refreshSchema)), async (req, res) => {
const errors = validationResult(req)

if (!errors.isEmpty()) {
Expand Down

0 comments on commit b9b7542

Please sign in to comment.