Routes /cas/login and /cas/logout
This commit is contained in:
parent
28938b679b
commit
0738cddcd6
3 changed files with 42 additions and 6 deletions
|
@ -414,6 +414,11 @@ export class SectionContent extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
const queryParams = this.props.location.search;
|
||||||
|
if (queryParams.indexOf('cas-login-success') > -1) this.setFlashMessage('success', 'Successful authentication');
|
||||||
|
if (queryParams.indexOf('cas-logout-success') > -1) this.setFlashMessage('success', 'Successful logout');
|
||||||
|
if (queryParams.indexOf('cas-login-error') > -1) this.setFlashMessage('danger', 'Fail authentication');
|
||||||
|
|
||||||
window.addEventListener('beforeunload', this.beforeUnloadHandler);
|
window.addEventListener('beforeunload', this.beforeUnloadHandler);
|
||||||
this.historyUnblock = this.props.history.block('Changes you made may not be saved. Are you sure you want to leave this page?');
|
this.historyUnblock = this.props.history.block('Changes you made may not be saved. Are you sure you want to leave this page?');
|
||||||
}
|
}
|
||||||
|
@ -445,7 +450,11 @@ export class SectionContent extends Component {
|
||||||
|
|
||||||
ensureAuthenticated() {
|
ensureAuthenticated() {
|
||||||
if (!mailtrainConfig.isAuthenticated) {
|
if (!mailtrainConfig.isAuthenticated) {
|
||||||
this.navigateTo('/login?next=' + encodeURIComponent(window.location.pathname));
|
if (mailtrainConfig.authMethod == 'cas') {
|
||||||
|
window.location.href=getUrl('cas/login?next=' + encodeURIComponent(window.location.pathname));
|
||||||
|
} else {
|
||||||
|
this.navigateTo('/login?next=' + encodeURIComponent(window.location.pathname));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +611,7 @@ export class DropdownLink extends Component {
|
||||||
|
|
||||||
const clsName = "dropdown-item" + (props.className ? " " + props.className : "")
|
const clsName = "dropdown-item" + (props.className ? " " + props.className : "")
|
||||||
return (
|
return (
|
||||||
<Link to={props.to} className={clsName}>{props.children}</Link>
|
<Link to={props.to} className={clsName} onClick={() => window.location.href=props.to}>{props.children}</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -729,4 +738,4 @@ export function getLanguageChooser(t) {
|
||||||
);
|
);
|
||||||
|
|
||||||
return languageChooser;
|
return languageChooser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,8 @@ export default class Login extends Component {
|
||||||
} else if (mailtrainConfig.externalPasswordResetLink) {
|
} else if (mailtrainConfig.externalPasswordResetLink) {
|
||||||
passwordResetLink = <a href={mailtrainConfig.externalPasswordResetLink}>{t('forgotYourPassword?')}</a>;
|
passwordResetLink = <a href={mailtrainConfig.externalPasswordResetLink}>{t('forgotYourPassword?')}</a>;
|
||||||
}
|
}
|
||||||
|
if (mailtrainConfig.authMethod != 'cas') {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Title>{t('signIn')}</Title>
|
<Title>{t('signIn')}</Title>
|
||||||
|
|
||||||
|
@ -126,6 +126,25 @@ export default class Login extends Component {
|
||||||
</ButtonRow>
|
</ButtonRow>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
if (mailtrainConfig.isAuthenticated) {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Title>{t('logOut')} CAS</Title>
|
||||||
|
{<a href="/cas/logout" class="btn btn-primary">{t('logOut')}</a>}
|
||||||
|
{passwordResetLink}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Title>{t('signIn')} CAS</Title>
|
||||||
|
{<a href="/cas/login" class="btn btn-primary">{t('signIn')}</a>}
|
||||||
|
{passwordResetLink}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,6 +324,14 @@ async function createApp(appType) {
|
||||||
app.use('/rest', reportsRest);
|
app.use('/rest', reportsRest);
|
||||||
}
|
}
|
||||||
install404Fallback('/rest');
|
install404Fallback('/rest');
|
||||||
|
if (config.cas && config.cas.enabled === true) {
|
||||||
|
app.get('/cas/login',
|
||||||
|
passport.authenticateCas,
|
||||||
|
function(req, res) {
|
||||||
|
res.redirect('/?cas-login-success');
|
||||||
|
});
|
||||||
|
app.get('/cas/logout', passport.logoutCas);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use('/', await index.getRouter(appType));
|
app.use('/', await index.getRouter(appType));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue