/**
|
* AuthenticationController.js
|
*
|
* This controller handles login
|
*/
|
|
|
const { OpusAuthenticationService } = require("../services/OpusAuthenticationService");
|
const { OAuth2AuthenticationService } = require("../services/OAuth2AuthenticationService");
|
|
let authenticationService;
|
|
if (sails.config.oauth && sails.config.oauth.useNewAuthentication === true) {
|
authenticationService = new OAuth2AuthenticationService();
|
}
|
else {
|
authenticationService = new OpusAuthenticationService();
|
}
|
|
module.exports = {
|
|
/**
|
* Login page
|
*
|
* GET /auth/login
|
*/
|
login: function (req, res) {
|
return authenticationService.login(req, res);
|
},
|
|
/**
|
* Login form
|
*
|
* POST /auth/login
|
*/
|
login_form: function (req, res) {
|
return authenticationService.login_form(req, res);
|
},
|
|
/**
|
* Logout
|
*
|
* POST /auth/logout
|
*/
|
logout: function (req, res) {
|
return authenticationService.logout(req, res);
|
},
|
|
/**
|
* OAuth Login Callback
|
*
|
* GET /auth/login/callback
|
*/
|
callback(req, res) {
|
return authenticationService.callback(req, res);
|
},
|
|
/**
|
* OAuth Logout Callback
|
*
|
* POST /auth/logout/back-channel
|
*/
|
backchannelLogout(req, res) {
|
return authenticationService.backchannelLogout(req, res);
|
}
|
};
|