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({
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,
notifications: null,
loadingNotifications: false,
needs: ['application'],
showSignUpButton: Em.computed.alias('controllers.application.canSignUp'),
showStarButton: function() {
return Discourse.User.current() && !this.get('topic.isPrivateMessage');

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
moduleFor('controller:topic', 'controller:topic', {
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() {