mirror of
https://github.com/ansible/awx.git
synced 2026-02-15 10:10:01 -03:30
add test coverage for auth utils
This commit is contained in:
@@ -78,7 +78,7 @@ export function main (render) {
|
||||
<I18n>
|
||||
{({ i18n }) => (
|
||||
<Background>
|
||||
{!isAuthenticated() ? loginRoutes : (
|
||||
{!isAuthenticated(document.cookie) ? loginRoutes : (
|
||||
<Switch>
|
||||
{removeTrailingSlash}
|
||||
<Route path="/login" render={defaultRedirect} />
|
||||
|
||||
@@ -110,7 +110,7 @@ class AWXLogin extends Component {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isAuthenticated()) {
|
||||
if (isAuthenticated(document.cookie)) {
|
||||
return (<Redirect to="/" />);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function isAuthenticated () {
|
||||
const parsed = (`; ${document.cookie}`).split('; userLoggedIn=');
|
||||
export function isAuthenticated (cookie) {
|
||||
const parsed = (`; ${cookie}`).split('; userLoggedIn=');
|
||||
if (parsed.length === 2) {
|
||||
return parsed.pop().split(';').shift() === 'true';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user