mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-19 04:14:40 +00:00
removing accesscontrol for now, but at least only subscribing to the
necessary data
This commit is contained in:
parent
71a4430efc
commit
e2c5096311
4 changed files with 13 additions and 23 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// Generated by CoffeeScript 1.3.3
|
||||
var content, derby, get, getHabits, helpers, ready, schema, scoring, view, _ref;
|
||||
var content, derby, get, helpers, ready, schema, scoring, view, _ref;
|
||||
|
||||
derby = require('derby');
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ get('/:uidParam?', function(page, model, _arg) {
|
|||
var uidParam, userId;
|
||||
uidParam = _arg.uidParam;
|
||||
userId = model.get('_userId');
|
||||
return model.fetch("users." + userId, function(err, user) {
|
||||
return model.subscribe("users." + userId, function(err, user) {
|
||||
var guid, newUser, task, _i, _len, _ref1;
|
||||
if (!user.get('id')) {
|
||||
newUser = schema.userSchema;
|
||||
|
|
@ -48,12 +48,6 @@ get('/:uidParam?', function(page, model, _arg) {
|
|||
}
|
||||
model.set("users." + userId, newUser);
|
||||
}
|
||||
return getHabits(page, model, userId);
|
||||
});
|
||||
});
|
||||
|
||||
getHabits = function(page, model, userId) {
|
||||
return model.subscribe("users." + userId, function(err, user) {
|
||||
model.ref('_user', user);
|
||||
model.set('_items', {
|
||||
armor: content.items.armor[parseInt(user.get('items.armor')) + 1],
|
||||
|
|
@ -71,7 +65,7 @@ getHabits = function(page, model, userId) {
|
|||
model.refList("_rewardList", "_user.tasks", "_user.rewardIds");
|
||||
return page.render();
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
ready(function(model) {
|
||||
var poormanscron, setupSortable, step, tour, type, _i, _j, _len, _len1, _ref1, _ref2;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ module.exports.queries = function(store) {
|
|||
};
|
||||
|
||||
module.exports.accessControl = function(store) {
|
||||
store.accessControl = true;
|
||||
store.readPathAccess('users.*', function(userId, accept) {
|
||||
console.log(accept, 'read.accept');
|
||||
return accept(userId === this.session.userId);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ get '/:uidParam?', (page, model, {uidParam}) ->
|
|||
# The session middleware will assign a _userId automatically
|
||||
userId = model.get '_userId'
|
||||
|
||||
model.fetch "users.#{userId}", (err, user) ->
|
||||
model.subscribe "users.#{userId}", (err, user) ->
|
||||
|
||||
# Else, select a new userId and initialize user
|
||||
# Create new user if none exists
|
||||
unless user.get('id')
|
||||
newUser = schema.userSchema
|
||||
for task in content.defaultTasks
|
||||
|
|
@ -32,14 +32,8 @@ get '/:uidParam?', (page, model, {uidParam}) ->
|
|||
when 'todo' then newUser.todoIds.push guid
|
||||
when 'reward' then newUser.rewardIds.push guid
|
||||
model.set "users.#{userId}", newUser
|
||||
|
||||
getHabits(page, model, userId)
|
||||
|
||||
getHabits = (page, model, userId) ->
|
||||
|
||||
model.subscribe "users.#{userId}", (err, user) ->
|
||||
# console.log {userId:userId, err:err}, "app/index.coffee: model.subscribe"
|
||||
# => {userId: 26c48325-2fea-4e2e-a60f-a5fa28d7b410, err: Unauthorized: No access control declared for path users.26c48325-2fea-4e2e-a60f-a5fa28d7b410 }
|
||||
# /end create new user
|
||||
|
||||
model.ref '_user', user
|
||||
|
||||
# Store
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
# expose query motifs
|
||||
module.exports.queries = (store) ->
|
||||
store.query.expose 'users', 'withId', (id) ->
|
||||
@byId(id)
|
||||
|
||||
# setup accessControl
|
||||
module.exports.accessControl = (store) ->
|
||||
|
||||
store.accessControl = true
|
||||
# store.accessControl = true
|
||||
|
||||
# FIXME
|
||||
# getting Property 'callback' of object 0,b800598e-0cc5-41e7-931f-431b8888e07a.2,set,users.be06f5d3-5ffd-4a9a-828f-87c5f43d3562,[object Object] is not a function
|
||||
# at Object.module.exports.server._commit.res.fail (node_modules/derby/node_modules/racer/lib/txns/txns.Model.js:319:22)
|
||||
# at node_modules/derby/node_modules/racer/lib/accessControl/accessControl.Store.js:221:34
|
||||
|
||||
store.readPathAccess 'users.*', (userId, accept) ->
|
||||
console.log accept, 'read.accept'
|
||||
|
|
|
|||
Loading…
Reference in a new issue