Compare commits

...

1 Commits

Author SHA1 Message Date
Syed Sajjad Hussain Shah
db75d5046d test: temp changes for embedded authn poc 2023-06-06 18:50:45 +05:00
4 changed files with 88 additions and 79 deletions

View File

@@ -23,6 +23,9 @@ const UnAuthOnlyRoute = (props) => {
if (isReady) { if (isReady) {
if (authUser && authUser.username) { if (authUser && authUser.username) {
if (true) { // check for query param
window.parent.postMessage({ authenticated: true }, 'https://discover.edx.org/social-reg');
}
global.location.href = getConfig().LMS_BASE_URL.concat(DEFAULT_REDIRECT_URL); global.location.href = getConfig().LMS_BASE_URL.concat(DEFAULT_REDIRECT_URL);
return null; return null;
} }

View File

@@ -231,7 +231,9 @@ class LoginPage extends React.Component {
tpaAuthenticationError.errorCode = TPA_AUTHENTICATION_FAILURE; tpaAuthenticationError.errorCode = TPA_AUTHENTICATION_FAILURE;
} }
if (this.props.loginResult.success) { if (this.props.loginResult.success) {
window.parent.postMessage({ loggedin: true, redirectUrl: this.props.loginResult.redirectUrl }, 'https://discover.edx.org/social-reg');
setSurveyCookie('login'); setSurveyCookie('login');
return null;
} }
return ( return (
@@ -241,11 +243,11 @@ class LoginPage extends React.Component {
{ siteName: getConfig().SITE_NAME })} { siteName: getConfig().SITE_NAME })}
</title> </title>
</Helmet> </Helmet>
<RedirectLogistration {/*<RedirectLogistration*/}
success={this.props.loginResult.success} {/* success={this.props.loginResult.success}*/}
redirectUrl={this.props.loginResult.redirectUrl} {/* redirectUrl={this.props.loginResult.redirectUrl}*/}
finishAuthUrl={thirdPartyAuthContext.finishAuthUrl} {/* finishAuthUrl={thirdPartyAuthContext.finishAuthUrl}*/}
/> {/*/>*/}
<div className="mw-xs mt-3"> <div className="mw-xs mt-3">
<ThirdPartyAuthAlert <ThirdPartyAuthAlert
currentProvider={thirdPartyAuthContext.currentProvider} currentProvider={thirdPartyAuthContext.currentProvider}
@@ -292,16 +294,16 @@ class LoginPage extends React.Component {
onClick={this.handleSubmit} onClick={this.handleSubmit}
onMouseDown={(e) => e.preventDefault()} onMouseDown={(e) => e.preventDefault()}
/> />
<Link {/*<Link*/}
id="forgot-password" {/* id="forgot-password"*/}
name="forgot-password" {/* name="forgot-password"*/}
className="btn btn-link font-weight-500 text-body" {/* className="btn btn-link font-weight-500 text-body"*/}
to={updatePathWithQueryParams(RESET_PAGE)} {/* to={updatePathWithQueryParams(RESET_PAGE)}*/}
onClick={this.handleForgotPasswordLinkClickEvent} {/* onClick={this.handleForgotPasswordLinkClickEvent}*/}
> {/*>*/}
{intl.formatMessage(messages['forgot.password'])} {/* {intl.formatMessage(messages['forgot.password'])}*/}
</Link> {/*</Link>*/}
{this.renderThirdPartyAuth(providers, secondaryProviders, currentProvider, thirdPartyAuthApiStatus, intl)} {/*{this.renderThirdPartyAuth(providers, secondaryProviders, currentProvider, thirdPartyAuthApiStatus, intl)}*/}
</Form> </Form>
</div> </div>
</> </>

View File

@@ -81,56 +81,56 @@ const Logistration = (props) => {
}; };
return ( return (
<BaseComponent> // <BaseComponent>
<div> <div className="d-flex justify-content-center">
{disablePublicAccountCreation {disablePublicAccountCreation
? ( ? (
<> <>
<Redirect to={updatePathWithQueryParams(LOGIN_PAGE)} /> <Redirect to={updatePathWithQueryParams(LOGIN_PAGE)} />
{institutionLogin && ( {institutionLogin && (
<Tabs defaultActiveKey="" id="controlled-tab" onSelect={handleInstitutionLogin}> <Tabs defaultActiveKey="" id="controlled-tab" onSelect={handleInstitutionLogin}>
<Tab title={tabTitle} eventKey={LOGIN_PAGE} /> <Tab title={tabTitle} eventKey={LOGIN_PAGE} />
</Tabs> </Tabs>
)}
<div id="main-content" className="main-content">
{!institutionLogin && (
<h3 className="mb-4.5">{formatMessage(messages['logistration.sign.in'])}</h3>
)} )}
<div id="main-content" className="main-content"> <LoginPage institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} />
{!institutionLogin && (
<h3 className="mb-4.5">{formatMessage(messages['logistration.sign.in'])}</h3>
)}
<LoginPage institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} />
</div>
</>
)
: (
<div>
{institutionLogin
? (
<Tabs defaultActiveKey="" id="controlled-tab" onSelect={handleInstitutionLogin}>
<Tab title={tabTitle} eventKey={selectedPage === LOGIN_PAGE ? LOGIN_PAGE : REGISTER_PAGE} />
</Tabs>
)
: (!isValidTpaHint() && (
<Tabs defaultActiveKey={selectedPage} id="controlled-tab" onSelect={handleOnSelect}>
<Tab title={formatMessage(messages['logistration.register'])} eventKey={REGISTER_PAGE} />
<Tab title={formatMessage(messages['logistration.sign.in'])} eventKey={LOGIN_PAGE} />
</Tabs>
))}
{ key && (
<Redirect to={updatePathWithQueryParams(key)} />
)}
<div id="main-content" className="main-content">
{selectedPage === LOGIN_PAGE
? <LoginPage institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} />
: (
<RegistrationPage
institutionLogin={institutionLogin}
handleInstitutionLogin={handleInstitutionLogin}
/>
)}
</div>
</div> </div>
)} </>
</div> )
</BaseComponent> : (
<div>
{institutionLogin
? (
<Tabs defaultActiveKey="" id="controlled-tab" onSelect={handleInstitutionLogin}>
<Tab title={tabTitle} eventKey={selectedPage === LOGIN_PAGE ? LOGIN_PAGE : REGISTER_PAGE} />
</Tabs>
)
: (!isValidTpaHint() && (
<Tabs defaultActiveKey={selectedPage} id="controlled-tab" onSelect={handleOnSelect}>
<Tab title={formatMessage(messages['logistration.register'])} eventKey={REGISTER_PAGE} />
<Tab title={formatMessage(messages['logistration.sign.in'])} eventKey={LOGIN_PAGE} />
</Tabs>
))}
{ key && (
<Redirect to={updatePathWithQueryParams(key)} />
)}
<div id="main-content" className="main-content">
{selectedPage === LOGIN_PAGE
? <LoginPage institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} />
: (
<RegistrationPage
institutionLogin={institutionLogin}
handleInstitutionLogin={handleInstitutionLogin}
/>
)}
</div>
</div>
)}
</div>
// </BaseComponent>
); );
}; };

View File

@@ -510,20 +510,24 @@ const RegistrationPage = (props) => {
/> />
); );
} }
if (registrationResult.success) {
window.parent.postMessage({ loggedin: true, redirectUrl: registrationResult.redirectUrl }, 'https://discover.edx.org/social-reg');
return null;
}
return ( return (
<> <>
<Helmet> <Helmet>
<title>{formatMessage(messages['register.page.title'], { siteName: getConfig().SITE_NAME })}</title> <title>{formatMessage(messages['register.page.title'], { siteName: getConfig().SITE_NAME })}</title>
</Helmet> </Helmet>
<RedirectLogistration {/*<RedirectLogistration*/}
success={registrationResult.success} {/* success={registrationResult.success}*/}
redirectUrl={registrationResult.redirectUrl} {/* redirectUrl={registrationResult.redirectUrl}*/}
finishAuthUrl={finishAuthUrl} {/* finishAuthUrl={finishAuthUrl}*/}
optionalFields={optionalFields} {/* optionalFields={optionalFields}*/}
redirectToProgressiveProfilingPage={ {/* redirectToProgressiveProfilingPage={*/}
getConfig().ENABLE_PROGRESSIVE_PROFILING_ON_AUTHN && Object.keys(optionalFields).includes('fields') {/* getConfig().ENABLE_PROGRESSIVE_PROFILING_ON_AUTHN && Object.keys(optionalFields).includes('fields')*/}
} {/* }*/}
/> {/*/>*/}
{autoSubmitRegisterForm && !errorCode.type ? ( {autoSubmitRegisterForm && !errorCode.type ? (
<div className="mw-xs mt-5 text-center"> <div className="mw-xs mt-5 text-center">
<Spinner animation="border" variant="primary" id="tpa-spinner" /> <Spinner animation="border" variant="primary" id="tpa-spinner" />
@@ -613,13 +617,13 @@ const RegistrationPage = (props) => {
onClick={handleSubmit} onClick={handleSubmit}
onMouseDown={(e) => e.preventDefault()} onMouseDown={(e) => e.preventDefault()}
/> />
<ThirdPartyAuth {/*<ThirdPartyAuth*/}
currentProvider={currentProvider} {/* currentProvider={currentProvider}*/}
providers={providers} {/* providers={providers}*/}
secondaryProviders={secondaryProviders} {/* secondaryProviders={secondaryProviders}*/}
handleInstitutionLogin={handleInstitutionLogin} {/* handleInstitutionLogin={handleInstitutionLogin}*/}
thirdPartyAuthApiStatus={thirdPartyAuthApiStatus} {/* thirdPartyAuthApiStatus={thirdPartyAuthApiStatus}*/}
/> {/*/>*/}
</Form> </Form>
</div> </div>
)} )}