FIX: Don't show Sign Up button in cases where users can't sign up

This commit is contained in:
Robin Ward 2014-08-12 16:55:23 -04:00
parent 532726005b
commit 11e43bd434
6 changed files with 18 additions and 6 deletions

View File

@ -1,3 +1,9 @@
export default Ember.Controller.extend({ export default Ember.Controller.extend({
styleCategory: null, styleCategory: null,
canSignUp: function() {
return !Discourse.SiteSettings.invite_only &&
Discourse.SiteSettings.allow_new_registrations &&
!Discourse.SiteSettings.enable_sso;
}.property(),
}); });

View File

@ -11,6 +11,9 @@ export default Discourse.Controller.extend({
showExtraInfo: null, showExtraInfo: null,
notifications: null, notifications: null,
loadingNotifications: false, loadingNotifications: false,
needs: ['application'],
showSignUpButton: Em.computed.alias('controllers.application.canSignUp'),
showStarButton: function() { showStarButton: function() {
return Discourse.User.current() && !this.get('topic.isPrivateMessage'); return Discourse.User.current() && !this.get('topic.isPrivateMessage');

View File

@ -8,7 +8,7 @@
@module Discourse @module Discourse
**/ **/
export default Discourse.Controller.extend(Discourse.ModalFunctionality, { export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
needs: ['modal', 'createAccount'], needs: ['modal', 'createAccount', 'application'],
authenticate: null, authenticate: null,
loggingIn: false, loggingIn: false,
loggedIn: false, loggedIn: false,
@ -37,8 +37,7 @@ export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
loginDisabled: Em.computed.or('loggingIn', 'loggedIn'), loginDisabled: Em.computed.or('loggingIn', 'loggedIn'),
showSignupLink: function() { showSignupLink: function() {
return !Discourse.SiteSettings.invite_only && return this.get('controllers.application.canSignUp') &&
Discourse.SiteSettings.allow_new_registrations &&
!this.get('loggingIn') && !this.get('loggingIn') &&
this.blank('authenticate'); this.blank('authenticate');
}.property('loggingIn', 'authenticate'), }.property('loggingIn', 'authenticate'),
@ -77,7 +76,7 @@ export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
$hidden_login_form.submit(); $hidden_login_form.submit();
} }
}, function(e) { }, function() {
// Failed to login // Failed to login
if (self.blank('loginName') || self.blank('loginPassword')) { if (self.blank('loginName') || self.blank('loginPassword')) {
self.flash(I18n.t('login.blank_username_or_password'), 'error'); self.flash(I18n.t('login.blank_username_or_password'), 'error');

View File

@ -41,9 +41,11 @@
</div> </div>
{{/unless}} {{/unless}}
{{#unless currentUser}} {{#unless currentUser}}
{{#if showSignUpButton}}
<button {{action showCreateAccount}} class='btn btn-primary btn-small sign-up-button'> <button {{action showCreateAccount}} class='btn btn-primary btn-small sign-up-button'>
{{i18n sign_up}} {{i18n sign_up}}
</button> </button>
{{/if}}
<button {{action showLogin}} class='btn btn-primary btn-small login-button'> <button {{action showLogin}} class='btn btn-primary btn-small login-button'>
{{icon user}} {{i18n log_in}} {{icon user}} {{i18n log_in}}
</button> </button>

View File

@ -1,4 +1,6 @@
moduleFor("controller:header", "controller:header"); moduleFor("controller:header", "controller:header", {
needs: ['controller:application']
});
test("showNotifications action", function() { test("showNotifications action", function() {
var resolveRequestWith; var resolveRequestWith;

View File

@ -1,6 +1,6 @@
moduleFor('controller:topic', 'controller:topic', { moduleFor('controller:topic', 'controller:topic', {
needs: ['controller:header', 'controller:modal', 'controller:composer', 'controller:quote-button', needs: ['controller:header', 'controller:modal', 'controller:composer', 'controller:quote-button',
'controller:search', 'controller:topic-progress'] 'controller:search', 'controller:topic-progress', 'controller:application']
}); });
var buildTopic = function() { var buildTopic = function() {