-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issueid #231004 feat:play youtube help video in mylearning iframe #219
Changes from 2 commits
fb4f571
caf4d24
5999899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -647,14 +647,15 @@ | |
|
||
const { virtualId } = useSelector((state) => state.user); | ||
|
||
const [isVideoOpen, setIsVideoOpen] = useState(false); | ||
|
||
const handleOpenVideo = () => { | ||
setIsVideoOpen(true); | ||
}; | ||
|
||
const handleCloseVideo = () => { | ||
setIsVideoOpen(false); | ||
if (process.env.REACT_APP_SHOW_HELP_VIDEO === "true") { | ||
window.parent.postMessage( | ||
{ | ||
message: "help-video-link", | ||
}, | ||
"*" | ||
); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add origin verification to postMessage for security The current implementation of Apply this fix: if (process.env.REACT_APP_SHOW_HELP_VIDEO === "true") {
window.parent.postMessage(
{
message: "help-video-link",
},
- "*"
+ process.env.REACT_APP_PARENT_ORIGIN || window.location.origin
);
} Also, ensure to add
🧰 Tools🪛 GitHub Check: SonarCloud[failure] 652-652: Origins should be verified during cross-origin communications Specify a target origin for this message.See more on SonarQube Cloud |
||
}; | ||
|
||
const navigate = useNavigate(); | ||
|
@@ -855,48 +856,6 @@ | |
</Box> | ||
</MainLayout> | ||
)} | ||
{/* Video Modal */} | ||
<Dialog | ||
open={isVideoOpen} | ||
onClose={handleCloseVideo} | ||
maxWidth="lg" | ||
fullWidth | ||
> | ||
<Box | ||
sx={{ | ||
position: "relative", | ||
width: "100%", | ||
paddingTop: "56.25%", // Maintain 16:9 aspect ratio | ||
backgroundColor: "black", // Optional: Ensure a dark background | ||
}} | ||
> | ||
<iframe | ||
src={process.env.REACT_APP_SHOW_HELP_VIDEO_LINK} | ||
title="YouTube video" | ||
frameBorder="0" | ||
allow="autoplay; encrypted-media" | ||
allowFullScreen | ||
style={{ | ||
position: "absolute", | ||
top: 0, | ||
left: 0, | ||
width: "100%", | ||
height: "100%", | ||
}} | ||
/> | ||
</Box> | ||
<IconButton | ||
onClick={handleCloseVideo} | ||
sx={{ | ||
position: "absolute", | ||
top: 8, | ||
right: 8, | ||
zIndex: 1, | ||
}} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</Dialog> | ||
</> | ||
); | ||
}; | ||
|
Check failure
Code scanning / SonarCloud
Origins should be verified during cross-origin communications High