mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add validation for login
This commit is contained in:
1 parent
fc6ac11c60
commit
203114cd5e
6 files changed
+44
-24
No files matched your search
@@ -11,34 +11,28 @@ import {
|
||||
registerFromSession,
|
||||
} from '../controllers/authController.js'
|
||||
import {
|
||||
checkNewEmail,
|
||||
checkNewUsername,
|
||||
checkPassword,
|
||||
checkUsernameValidators,
|
||||
loginValidators,
|
||||
registerFromSessionValidators,
|
||||
registerValidators,
|
||||
} from '../validators/authValidator.js'
|
||||
import { noError } from '../../middleware/validator.js'
|
||||
|
||||
const router = Router()
|
||||
|
||||
router.post(
|
||||
'/login',
|
||||
loginValidators,
|
||||
passport.authenticate('local', { failureMessage: true }),
|
||||
(req, res) => {
|
||||
res.json({ message: 'success' })
|
||||
}
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/register',
|
||||
checkNewUsername(),
|
||||
checkNewEmail(),
|
||||
checkPassword(),
|
||||
noError,
|
||||
register
|
||||
)
|
||||
router.post('/register', registerValidators, register)
|
||||
|
||||
router.post('/logout', logout)
|
||||
|
||||
router.get('/check-username', checkNewUsername(), noError, (req, res) =>
|
||||
router.get('/check-username', checkUsernameValidators, (req, res) =>
|
||||
res.json({ available: true })
|
||||
)
|
||||
router.get('/check-session', checkSession)
|
||||
@@ -59,8 +53,7 @@ if (enabledMethods.github) {
|
||||
|
||||
router.post(
|
||||
'/register-from-session',
|
||||
checkNewUsername(),
|
||||
noError,
|
||||
registerFromSessionValidators,
|
||||
registerFromSession
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user