@@ -234,7 +234,22 @@ export default class Status extends React.Component {
234234 cookies ,
235235 ) ;
236236 this . notifyCpLogin ( userData ) ;
237- this . loginFormRef . current . submit ( ) ;
237+ try {
238+ const formAction = new URL ( this . loginFormRef . current . action ) ;
239+ if (
240+ window . location . protocol === "https:" &&
241+ formAction . protocol === "http:"
242+ ) {
243+ throw new Error (
244+ "Mixed Content: Cannot submit insecure HTTP form from a secure HTTPS page." ,
245+ ) ;
246+ }
247+ this . loginFormRef . current . submit ( ) ;
248+ } catch ( error ) {
249+ this . context . setLoading ( false ) ;
250+ toast . error ( `Security/Network Error: ${ error . message } ` ) ;
251+ console . error ( "Mixed Content Exception:" , error ) ;
252+ }
238253 } else if ( ! shouldLogin ) {
239254 // If the user is already logged in, we need to handle the
240255 // the response from the captive portal.
@@ -588,7 +603,22 @@ export default class Status extends React.Component {
588603 true ,
589604 cookies ,
590605 ) ;
591- this . logoutFormRef . current . submit ( ) ;
606+ try {
607+ const formAction = new URL ( this . logoutFormRef . current . action ) ;
608+ if (
609+ window . location . protocol === "https:" &&
610+ formAction . protocol === "http:"
611+ ) {
612+ throw new Error (
613+ "Mixed Content: Cannot submit insecure HTTP form from a secure HTTPS page." ,
614+ ) ;
615+ }
616+ this . logoutFormRef . current . submit ( ) ;
617+ } catch ( error ) {
618+ this . context . setLoading ( false ) ;
619+ toast . error ( `Security/Network Error: ${ error . message } ` ) ;
620+ console . error ( "Mixed Content Exception:" , error ) ;
621+ }
592622 }
593623 return ;
594624 }
@@ -900,7 +930,21 @@ export default class Status extends React.Component {
900930 } ) ;
901931 const { setLoading} = this . context ;
902932 if ( this . logoutFormRef && this . logoutFormRef . current ) {
903- this . logoutFormRef . current . submit ( ) ;
933+ try {
934+ const formAction = new URL ( this . logoutFormRef . current . action ) ;
935+ if (
936+ window . location . protocol === "https:" &&
937+ formAction . protocol === "http:"
938+ ) {
939+ throw new Error (
940+ "Mixed Content: Cannot submit insecure HTTP form from a secure HTTPS page." ,
941+ ) ;
942+ }
943+ this . logoutFormRef . current . submit ( ) ;
944+ } catch ( error ) {
945+ setLoading ( false ) ;
946+ toast . error ( error . message ) ;
947+ }
904948 }
905949 setLoading ( true ) ;
906950 await this . getUserPastRadiusSessions ( ) ;
0 commit comments