Browse Source

WIP banned user

Rafał Pitoń 10 years ago
parent
commit
4b8bf0c147

+ 10 - 7
misago/emberapp/app/controllers/login-modal.js

@@ -5,13 +5,14 @@ import getCsrfToken from 'misago/utils/csrf';
 export default Ember.Controller.extend({
 export default Ember.Controller.extend({
   modal: null,
   modal: null,
 
 
-  message: '',
+  isLoading: false,
+  isBanned: false,
+  showActivation: false,
 
 
   username: '',
   username: '',
   password: '',
   password: '',
 
 
-  isLoading: false,
-  showActivation: false,
+  ban: null,
 
 
   scheduleSetup: function() {
   scheduleSetup: function() {
     Ember.run.scheduleOnce('afterRender', this, this.setup);
     Ember.run.scheduleOnce('afterRender', this, this.setup);
@@ -31,18 +32,17 @@ export default Ember.Controller.extend({
   },
   },
 
 
   reset: function() {
   reset: function() {
-    this.set('message', '');
+    this.set('ban', null);
 
 
     this.set('username', '');
     this.set('username', '');
     this.set('password', '');
     this.set('password', '');
 
 
     this.set('isLoading', false);
     this.set('isLoading', false);
+    this.set('isBanned', false);
     this.set('showActivation', false);
     this.set('showActivation', false);
   },
   },
 
 
   isValid: function(credentials) {
   isValid: function(credentials) {
-    this.set('isLoading', true);
-
     if (!credentials.username || !credentials.password) {
     if (!credentials.username || !credentials.password) {
       this.send('flashWarning', gettext("Fill out both fields."));
       this.send('flashWarning', gettext("Fill out both fields."));
       return false;
       return false;
@@ -83,6 +83,8 @@ export default Ember.Controller.extend({
       this.send('flashInfo', rejection.detail);
       this.send('flashInfo', rejection.detail);
       this.set('showActivation', true);
       this.set('showActivation', true);
     } else if (rejection.code === 'banned') {
     } else if (rejection.code === 'banned') {
+      this.set('ban', rejection.detail);
+      this.set('isBanned', true);
     } else {
     } else {
       this.send('flashError', rejection.detail);
       this.send('flashError', rejection.detail);
     }
     }
@@ -101,11 +103,12 @@ export default Ember.Controller.extend({
         };
         };
 
 
         if (this.isValid(credentials)) {
         if (this.isValid(credentials)) {
+          this.set('isLoading', true);
           this.authenticate(credentials);
           this.authenticate(credentials);
         } else {
         } else {
           this.set('isLoading', false);
           this.set('isLoading', false);
         }
         }
       }
       }
-    }
+    },
   }
   }
 });
 });

+ 7 - 0
misago/emberapp/app/styles/misago/modals.less

@@ -17,6 +17,13 @@
     .form-group {
     .form-group {
       margin: @padding-large-vertical 0px;
       margin: @padding-large-vertical 0px;
     }
     }
+
+    &.modal-ban-message {
+      p {
+        margin-top: @padding-large-vertical;
+        margin-bottom: @padding-large-vertical;
+      }
+    }
   }
   }
 
 
   .modal-footer {
   .modal-footer {

+ 19 - 0
misago/emberapp/app/templates/login-modal.hbs

@@ -2,8 +2,26 @@
   <div class="modal-dialog modal-sm modal-sign-in">
   <div class="modal-dialog modal-sm modal-sign-in">
     <div class="modal-content">
     <div class="modal-content">
       <div class="modal-header">
       <div class="modal-header">
+        <button type="button" class="close" data-dismiss="modal" aria-label="{{unbound gettext "Close"}}"><span aria-hidden="true">&times;</span></button>
+        {{#if isBanned}}
+        <h4 class="modal-title" id="loginModalLabel">{{gettext "Account banned"}}</h4>
+        {{else}}
         <h4 class="modal-title" id="loginModalLabel">{{gettext "Sign in"}}</h4>
         <h4 class="modal-title" id="loginModalLabel">{{gettext "Sign in"}}</h4>
+        {{/if}}
+      </div>
+
+      {{#if isBanned}}
+      <div class="modal-body modal-ban-message">
+
+        {{{ban.message.html}}}
+
+        <p>This ban is permanent.</p>
+
+      </div>
+      <div class="modal-footer">
+        <button class="btn btn-block btn-default" data-dismiss="modal">{{gettext "Ok"}}</button>
       </div>
       </div>
+      {{else}}
       <div class="modal-body">
       <div class="modal-body">
 
 
         <div class="form-group">
         <div class="form-group">
@@ -36,6 +54,7 @@
         <button class="btn btn-block btn-default">{{gettext "Forgot password?"}}</button>
         <button class="btn btn-block btn-default">{{gettext "Forgot password?"}}</button>
 
 
       </div>
       </div>
+      {{/if}}
     </div>
     </div>
   </div>
   </div>
 </div>
 </div>