diff --git a/ibt2.py b/ibt2.py index 4b2ae82..f6bd3f5 100755 --- a/ibt2.py +++ b/ibt2.py @@ -370,10 +370,14 @@ class UsersHandler(CollectionHandler): @gen.coroutine def get(self, id_=None, **kwargs): if id_: + if str(self.current_user_info.get('_id')) != id_ and not self.current_user_info.get('isAdmin'): + return self.build_error(status=401, message='insufficient permissions: must be the owner or admin') output = self.db.getOne(self.collection, {'_id': id_}) if 'password' in output: del output['password'] else: + if not self.current_user_info.get('isAdmin'): + return self.build_error(status=401, message='insufficient permissions: must be an admin') output = {self.collection: self.db.query(self.collection, self.arguments)} for user in output['users']: if 'password' in user: @@ -410,19 +414,16 @@ class UsersHandler(CollectionHandler): self._clean_dict(data) if id_ is None: return self.build_error(status=404, message='unable to access the resource') - old_pwd = data.get('old_password') - new_pwd = data.get('new_password') - if old_pwd is not None: - del data['old_password'] - if new_pwd is not None: - del data['new_password'] - authorized, user = self.user_authorized(data['username'], old_pwd) - if not (authorized and self.current_user == data['username']): - raise InputException('not authorized to change password') - data['password'] = utils.hash_password(new_pwd) if '_id' in data: # Avoid overriding _id del data['_id'] + if 'username' in data: + del data['username'] + if 'password' in data: + if data['password']: + data['password'] = utils.hash_password(data['password']) + else: + del data['password'] if str(self.current_user_info.get('_id')) != id_ and not self.current_user_info.get('isAdmin'): return self.build_error(status=401, message='insufficient permissions: must be the owner or admin') merged, doc = self.db.update(self.collection, {'_id': id_}, data) diff --git a/src/Attendee.vue b/src/Attendee.vue index 6a28bbd..e71b4b3 100644 --- a/src/Attendee.vue +++ b/src/Attendee.vue @@ -5,12 +5,22 @@ - - edit - - - cancel - + + + + more_vert + + + + edit + edit + + + delete + cancel + + + diff --git a/src/Users.vue b/src/Users.vue new file mode 100644 index 0000000..3229ab8 --- /dev/null +++ b/src/Users.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/src/main.js b/src/main.js index de57299..f5d282c 100644 --- a/src/main.js +++ b/src/main.js @@ -12,6 +12,7 @@ import jQuery from 'jquery'; import store_data from './store.js'; import App from './App'; import User from './User'; +import Users from './Users'; import Toolbar from './Toolbar'; Vue.use(Vuex); @@ -20,10 +21,11 @@ Vue.use(VueResource); Vue.use(VueMaterial); var routes = [ - {path: '/', name: 'root', component: App}, + {path: '/', name: 'home', component: App}, {path: '/day/', name: 'days', component: App}, {path: '/day/:day', name: 'day', component: App}, - {path: '/user/:user', name: 'user', component: User} + {path: '/user/', name: 'users', component: Users}, + {path: '/user/:id', name: 'user', component: User} ]; const store = new Vuex.Store(store_data); @@ -46,5 +48,5 @@ var vue = new Vue({ store: store, template: '
', router: router, - components: { App, Toolbar, User } + components: { App, Toolbar, Users, User } });