Skip to content

Commit

Permalink
fix: Redirecting to MFE home page instead of access-denied page to sa…
Browse files Browse the repository at this point in the history
…ve redirection (#970)
  • Loading branch information
HammadAhmadWaqas authored Sep 7, 2022
1 parent f9806d0 commit 96ceab8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/alerts/active-enteprise-alert/ActiveEnterpriseAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { getConfig } from '@edx/frontend-platform';
import genericMessages from './messages';

function ActiveEnterpriseAlert({ intl, payload }) {
const { text } = payload;
const { text, courseId } = payload;
const changeActiveEnterprise = (
<Hyperlink
style={{ textDecoration: 'underline' }}
destination={
`${getConfig().LMS_BASE_URL}/enterprise/select/active/?success_url=${encodeURIComponent(global.location.href)}`
`${getConfig().LMS_BASE_URL}/enterprise/select/active/?success_url=${encodeURIComponent(
`${global.location.origin}/course/${courseId}/home`,
)}`
}
>
{intl.formatMessage(genericMessages.changeActiveEnterpriseLowercase)}
Expand All @@ -39,6 +41,7 @@ ActiveEnterpriseAlert.propTypes = {
intl: intlShape.isRequired,
payload: PropTypes.shape({
text: PropTypes.string,
courseId: PropTypes.string,
}).isRequired,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('ActiveEnterpriseAlert', () => {
const mockData = {
payload: {
text: 'test message',
courseId: 'test-course-id',
},
};
beforeAll(async () => {
Expand All @@ -20,7 +21,7 @@ describe('ActiveEnterpriseAlert', () => {
expect(screen.getByRole('alert')).toBeInTheDocument();
expect(screen.getByText('test message')).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'change enterprise now' })).toHaveAttribute(
'href', `${getConfig().LMS_BASE_URL}/enterprise/select/active/?success_url=http%3A%2F%2Flocalhost%2F`,
'href', `${getConfig().LMS_BASE_URL}/enterprise/select/active/?success_url=http%3A%2F%2Flocalhost%2Fcourse%2Ftest-course-id%2Fhome`,
);
});
});

0 comments on commit 96ceab8

Please sign in to comment.