]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11038 Fix redirect url when not logged in user access project create page
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 6 Aug 2018 13:20:03 +0000 (15:20 +0200)
committerSonarTech <sonartech@sonarsource.com>
Fri, 10 Aug 2018 18:21:31 +0000 (20:21 +0200)
server/sonar-web/src/main/js/apps/projects/create/CreateProjectPage.tsx

index f4ea23b49bb9667bbac77ba2ceb724977e995f00..fd86a11afeef9900be1f8f1ac95d654bff00bf89 100644 (file)
@@ -62,26 +62,26 @@ interface State {
 
 export class CreateProjectPage extends React.PureComponent<Props, State> {
   mounted = false;
-
-  constructor(props: Props) {
-    super(props);
-    this.state = { loading: true };
-    const query = parseQuery(props.location.query);
-    if (query.error) {
-      this.props.addGlobalErrorMessage(query.error);
-    }
-    if (!this.canAutoCreate(props)) {
-      this.updateQuery({ manual: true });
-    }
-  }
+  state: State = { loading: true };
 
   componentDidMount() {
-    this.mounted = true;
-    if (!isLoggedIn(this.props.currentUser)) {
+    if (isLoggedIn(this.props.currentUser)) {
+      this.mounted = true;
+      const query = parseQuery(this.props.location.query);
+      if (query.error) {
+        this.props.addGlobalErrorMessage(query.error);
+      }
+      if (!this.canAutoCreate()) {
+        this.setState({ loading: false });
+        this.updateQuery({ manual: true });
+      } else {
+        this.fetchIdentityProviders();
+      }
+      document.body.classList.add('white-page');
+      document.documentElement.classList.add('white-page');
+    } else {
       handleRequiredAuthentication();
     }
-    document.body.classList.add('white-page');
-    document.documentElement.classList.add('white-page');
   }
 
   componentWillUnmount() {
@@ -189,14 +189,14 @@ export class CreateProjectPage extends React.PureComponent<Props, State> {
                 </ul>
               )}
 
-              {displayManual || !hasAutoProvisioning ? (
+              {displayManual || !hasAutoProvisioning || !identityProvider ? (
                 <ManualProjectCreate
                   currentUser={currentUser}
                   onProjectCreate={this.handleProjectCreate}
                 />
               ) : (
                 <AutoProjectCreate
-                  identityProvider={identityProvider!}
+                  identityProvider={identityProvider}
                   onProjectCreate={this.handleProjectCreate}
                 />
               )}