REVERT: External auth when redeeming invites

REVERT: External auth when redeeming invites

Reverting this commit:

87a0a6664e4bcde2ec3ac012308d9c7fb8e0d370

because I’m extracting all of this logic into a plugin instead.

diff --git a/app/assets/javascripts/discourse/controllers/invites-show.js.es6 b/app/assets/javascripts/discourse/controllers/invites-show.js.es6
index a35f919..97eca20 100644
--- a/app/assets/javascripts/discourse/controllers/invites-show.js.es6
+++ b/app/assets/javascripts/discourse/controllers/invites-show.js.es6
@@ -5,7 +5,6 @@ import { ajax } from "discourse/lib/ajax";
 import PasswordValidation from "discourse/mixins/password-validation";
 import UsernameValidation from "discourse/mixins/username-validation";
 import NameValidation from "discourse/mixins/name-validation";
-import InviteEmailAuthValidation from "discourse/mixins/invite-email-auth-validation";
 import UserFieldsValidation from "discourse/mixins/user-fields-validation";
 import { findAll as findLoginMethods } from "discourse/models/login-method";
 
@@ -13,11 +12,8 @@ export default Ember.Controller.extend(
   PasswordValidation,
   UsernameValidation,
   NameValidation,
-  InviteEmailAuthValidation,
   UserFieldsValidation,
   {
-    login: Ember.inject.controller(),
-
     invitedBy: Ember.computed.alias("model.invited_by"),
     email: Ember.computed.alias("model.email"),
     accountUsername: Ember.computed.alias("model.username"),
@@ -26,7 +22,6 @@ export default Ember.Controller.extend(
     errorMessage: null,
     userFields: null,
     inviteImageUrl: getUrl("/images/envelope.svg"),
-    hasAuthOptions: Ember.computed.notEmpty("authOptions"),
 
     @computed
     welcomeTitle() {
@@ -40,45 +35,28 @@ export default Ember.Controller.extend(
       return I18n.t("invites.your_email", { email: email });
     },
 
-    authProviderDisplayName(providerName) {
-      const matchingProvider = findLoginMethods().find(provider => {
-        return provider.name === providerName;
-      });
-      return matchingProvider
-        ? matchingProvider.get("prettyName")
-        : providerName;
-    },
-
     @computed
     externalAuthsEnabled() {
       return findLoginMethods().length > 0;
     },
 
-    @computed
-    inviteOnlyOauthEnabled() {
-      return this.siteSettings.enable_invite_only_oauth;
-    },
-
     @computed(
       "usernameValidation.failed",
       "passwordValidation.failed",
       "nameValidation.failed",
-      "userFieldsValidation.failed",
-      "inviteEmailAuthValidation.failed"
+      "userFieldsValidation.failed"
     )
     submitDisabled(
       usernameFailed,
       passwordFailed,
       nameFailed,
-      userFieldsFailed,
-      inviteEmailAuthFailed
+      userFieldsFailed
     ) {
       return (
         usernameFailed ||
         passwordFailed ||
         nameFailed ||
-        userFieldsFailed ||
-        inviteEmailAuthFailed
+        userFieldsFailed
       );
     },
 
@@ -90,10 +68,6 @@ export default Ember.Controller.extend(
     },
 
     actions: {
-      externalLogin(provider) {
-        this.login.send("externalLogin", provider);
-      },
-
       submit() {
         const userFields = this.userFields;
         let userCustomFields = {};
diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6
index 76f33c9..19da455 100644
--- a/app/assets/javascripts/discourse/controllers/login.js.es6
+++ b/app/assets/javascripts/discourse/controllers/login.js.es6
@@ -20,7 +20,6 @@ const AuthErrors = [
 
 export default Ember.Controller.extend(ModalFunctionality, {
   createAccount: Ember.inject.controller(),
-  invitesShow: Ember.inject.controller(),
   forgotPassword: Ember.inject.controller(),
   application: Ember.inject.controller(),
 
@@ -354,23 +353,14 @@ export default Ember.Controller.extend(ModalFunctionality, {
       return;
     }
 
-    if (this.siteSettings.enable_invite_only_oauth) {
-      const invitesShowController = this.invitesShow;
-      invitesShowController.setProperties({
-        accountEmail: options.email,
-        accountUsername: options.username,
-        accountName: options.name,
-        authOptions: Ember.Object.create(options)
-      });
-    } else {
-      const createAccountController = this.createAccount;
-      createAccountController.setProperties({
-        accountEmail: options.email,
-        accountUsername: options.username,
-        accountName: options.name,
-        authOptions: Ember.Object.create(options)
-      });
-      showModal("createAccount");
-    }
+    const createAccountController = this.createAccount;
+    createAccountController.setProperties({
+      accountEmail: options.email,
+      accountUsername: options.username,
+      accountName: options.name,
+      authOptions: Ember.Object.create(options)
+    });
+
+    showModal("createAccount");
   }
 });
diff --git a/app/assets/javascripts/discourse/mixins/invite-email-auth-validation.js.es6 b/app/assets/javascripts/discourse/mixins/invite-email-auth-validation.js.es6
deleted file mode 100644
index d6cf80b..0000000
--- a/app/assets/javascripts/discourse/mixins/invite-email-auth-validation.js.es6
+++ /dev/null
@@ -1,43 +0,0 @@
-import InputValidation from "discourse/models/input-validation";
-import { default as computed } from "ember-addons/ember-computed-decorators";
-
-export default Ember.Mixin.create({
-  @computed()
-  nameInstructions() {
-    "";
-  },
-
-  // Validate the name.
-  @computed(
-    "accountEmail",
-    "authOptions.email",
-    "authOptions.email_valid",
-    "authOptions.auth_provider"
-  )
-  inviteEmailAuthValidation() {
-    if (
-      !this.siteSettings.enable_invite_only_oauth ||
-      (this.siteSettings.enable_invite_only_oauth &&
-        this.get("authOptions.email") === this.email &&
-        this.get("authOptions.email_valid"))
-    ) {
-      return InputValidation.create({
-        ok: true,
-        reason: I18n.t("user.email.authenticated", {
-          provider: this.authProviderDisplayName(
-            this.get("authOptions.auth_provider")
-          )
-        })
-      });
-    }
-
-    return InputValidation.create({
-      failed: true,
-      reason: I18n.t("user.email.invite_email_auth_invalid", {
-        provider: this.authProviderDisplayName(
-          this.get("authOptions.auth_provider")
-        )
-      })
-    });
-  }
-});
diff --git a/app/assets/javascripts/discourse/templates/invites/show.hbs b/app/assets/javascripts/discourse/templates/invites/show.hbs
index 467d918..6b3b461 100644
--- a/app/assets/javascripts/discourse/templates/invites/show.hbs
+++ b/app/assets/javascripts/discourse/templates/invites/show.hbs
@@ -14,98 +14,55 @@
       {{else}}
         <p>{{i18n 'invites.invited_by'}}</p>
         <p>{{user-info user=invitedBy}}</p>
-        <p>
-        {{{yourEmailMessage}}}
-        {{#if inviteOnlyOauthEnabled }}
-          {{login-buttons externalLogin=(action "externalLogin")}}
-        {{/if}}
+
+        <p>{{{yourEmailMessage}}}
         {{#if externalAuthsEnabled}}
-          {{#unless inviteOnlyOauthEnabled}}
-            {{i18n 'invites.social_login_available'}}
-          {{/unless}}
+             {{i18n 'invites.social_login_available'}}
         {{/if}}
         </p>
 
-        {{#if hasAuthOptions}}
-          {{#if inviteOnlyOauthEnabled }}
-            {{input-tip validation=inviteEmailAuthValidation id="account-email-validation"}}
-          {{/if}}
-          <form>
-            <div class="input username-input">
-              <label>{{i18n 'user.username.title'}}</label>
-              {{input value=accountUsername id="new-account-username" name="username" maxlength=maxUsernameLength autocomplete="discourse"}}
-              &nbsp;{{input-tip validation=usernameValidation id="username-validation"}}
-              <div class="instructions">{{i18n 'user.username.instructions'}}</div>
-            </div>
-
-            {{#if fullnameRequired}}
-              <div class="input name-input">
-                <label>{{i18n 'invites.name_label'}}</label>
-                {{input value=accountName id="new-account-name" name="name"}}
-                <div class="instructions">{{nameInstructions}}</div>

[... diff too long, it was truncated ...]

GitHub sha: 893d30fb

Ran prettier to fix build