|
|
@ -31,34 +31,51 @@ class AuthController extends SiteController {
|
|
|
|
|
|
|
|
|
|
|
|
const authRequired = this.dtp.services.session.authCheckMiddleware({ requireLogin: true });
|
|
|
|
const authRequired = this.dtp.services.session.authCheckMiddleware({ requireLogin: true });
|
|
|
|
|
|
|
|
|
|
|
|
router.post('/otp/enable',
|
|
|
|
router.post(
|
|
|
|
|
|
|
|
'/otp/enable',
|
|
|
|
limiterService.create(limiterService.config.auth.postOtpEnable),
|
|
|
|
limiterService.create(limiterService.config.auth.postOtpEnable),
|
|
|
|
this.postOtpEnable.bind(this),
|
|
|
|
this.postOtpEnable.bind(this),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
router.post('/otp/auth',
|
|
|
|
router.post(
|
|
|
|
|
|
|
|
'/otp/auth',
|
|
|
|
limiterService.create(limiterService.config.auth.postOtpAuthenticate),
|
|
|
|
limiterService.create(limiterService.config.auth.postOtpAuthenticate),
|
|
|
|
this.postOtpAuthenticate.bind(this),
|
|
|
|
this.postOtpAuthenticate.bind(this),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
router.post('/login',
|
|
|
|
router.post(
|
|
|
|
|
|
|
|
'/login',
|
|
|
|
limiterService.create(limiterService.config.auth.postLogin),
|
|
|
|
limiterService.create(limiterService.config.auth.postLogin),
|
|
|
|
upload.none(),
|
|
|
|
upload.none(),
|
|
|
|
this.postLogin.bind(this),
|
|
|
|
this.postLogin.bind(this),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
router.get('/api-token/personal',
|
|
|
|
router.get(
|
|
|
|
|
|
|
|
'/api-token/personal',
|
|
|
|
authRequired,
|
|
|
|
authRequired,
|
|
|
|
limiterService.create(limiterService.config.auth.getPersonalApiToken),
|
|
|
|
limiterService.create(limiterService.config.auth.getPersonalApiToken),
|
|
|
|
this.getPersonalApiToken.bind(this),
|
|
|
|
this.getPersonalApiToken.bind(this),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
router.get('/socket-token',
|
|
|
|
router.get(
|
|
|
|
|
|
|
|
'/socket-token',
|
|
|
|
authRequired,
|
|
|
|
authRequired,
|
|
|
|
limiterService.create(limiterService.config.auth.getSocketToken),
|
|
|
|
limiterService.create(limiterService.config.auth.getSocketToken),
|
|
|
|
this.getSocketToken.bind(this),
|
|
|
|
this.getSocketToken.bind(this),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
router.get('/logout',
|
|
|
|
router.get(
|
|
|
|
|
|
|
|
'/core',
|
|
|
|
|
|
|
|
passport.authenticate('oauth2'),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.get(
|
|
|
|
|
|
|
|
'/core/callback',
|
|
|
|
|
|
|
|
passport.authenticate('oauth2', { failureRedirect: '/' }),
|
|
|
|
|
|
|
|
this.getCoreCallback.bind(this),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.get(
|
|
|
|
|
|
|
|
'/logout',
|
|
|
|
authRequired,
|
|
|
|
authRequired,
|
|
|
|
limiterService.create(limiterService.config.auth.getLogout),
|
|
|
|
limiterService.create(limiterService.config.auth.getLogout),
|
|
|
|
this.getLogout.bind(this),
|
|
|
|
this.getLogout.bind(this),
|
|
|
@ -173,6 +190,16 @@ class AuthController extends SiteController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async getCoreCallback (req, res) {
|
|
|
|
|
|
|
|
// req.login(user, (error) => {
|
|
|
|
|
|
|
|
// if (error) {
|
|
|
|
|
|
|
|
// return next(error);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return res.redirect('/');
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
return res.redirect('/');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async getLogout (req, res, next) {
|
|
|
|
async getLogout (req, res, next) {
|
|
|
|
if (!req.user) {
|
|
|
|
if (!req.user) {
|
|
|
|
return next(new SiteError(403, 'You are not signed in'));
|
|
|
|
return next(new SiteError(403, 'You are not signed in'));
|
|
|
|