mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 00:15:15 +08:00
FIX: Don't show Sign Up button in cases where users can't sign up
This commit is contained in:
parent
532726005b
commit
11e43bd434
|
@ -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(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -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');
|
||||||
|
|
|
@ -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');
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user