Просмотр исходного кода

small auth service progression

Rafał Pitoń 10 лет назад
Родитель
Сommit
3db2ea116d

+ 1 - 1
misago/emberapp/app/initializers/auth-service.js

@@ -4,7 +4,7 @@ import Auth from 'misago/services/auth';
 export function initialize(container, application) {
   var auth = Auth.create({
     'isAuthenticated': PreloadStore.get('isAuthenticated'),
-    'user': PreloadStore.get('user')
+    'user': Ember.Object.create(PreloadStore.get('user'))
   });
 
   application.register('misago:auth', auth, { instantiate: false });

+ 9 - 3
misago/emberapp/app/services/auth.js

@@ -1,11 +1,17 @@
 import Ember from 'ember';
 
 export default Ember.Service.extend({
-  isAnonymous: function() {
-    return !this.get('isAuthenticated');
-  }.property('isAuthenticated'),
+  isAnonymous: Ember.computed.not('isAuthenticated'),
 
   logout: function() {
     Ember.$('#hidden-logout-form').submit();
   },
+
+  blockAuthenticated: function(message) {
+    // TODO: if user is authenticated, throw error 403 with message
+  },
+
+  blockAnonymous: function(message) {
+    // TODO: if user is not authenticated, throw error 403 with message
+  }
 });