todo-react-redux icon indicating copy to clipboard operation
todo-react-redux copied to clipboard

How can I make a task public?

Open KillerBee05 opened this issue 6 years ago • 11 comments

I made a new page for all users tasks to be shown. I set the Firebase Rules Read to true to anyone can see them. Any advice to what I need to do to see everyones data ?

KillerBee05 avatar Jul 07 '17 04:07 KillerBee05

Can you show a sample of your rules?

r-park avatar Jul 09 '17 06:07 r-park

I won't be at my computer until later tonight, but I set the read to tasks to true and write to false.

On Jul 9, 2017 12:34 AM, "Richard Park" [email protected] wrote:

Can you show a sample of your rules?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/r-park/todo-react-redux/issues/70#issuecomment-313902242, or mute the thread https://github.com/notifications/unsubscribe-auth/AUN_jNO_8xn-B5C-8W4EceixtTbfHyb-ks5sMHRtgaJpZM4OQeVu .

KillerBee05 avatar Jul 09 '17 13:07 KillerBee05

So what I'm trying to do is have people who are both authenticated and not authenticated to see tasks on the landing page. However it's still blank when I set permissions to true. I also tried to set just the path to tasks/ in the actions.js in the loadTasks () function. But the issue there is that it can't get past each individual authentication key. So I get an error there as well. What I'm thinking is that when I save a task I need to get rid of the authentication key and just save each record without it. If you know a solution that would be a big help!

KillerBee05 avatar Jul 09 '17 13:07 KillerBee05

In order to use path /tasks to get all tasks, you would need to modify your rules to something like:

{
  "rules": {
    "tasks": {
      ".read": true,

      "$uid": {
        ".read": true,
        ".write": "auth !== null && auth.uid === $uid",
        ".indexOn": ["completed"]
      }
    }
  }
}

r-park avatar Jul 09 '17 21:07 r-park

Okay cool. I will try that as soon as I can and let you know! Thanks

On Jul 9, 2017 3:46 PM, "Richard Park" [email protected] wrote:

In order to use path /tasks to get all tasks, you would need to modify your rules to something like:

{ "rules": { "tasks": { ".read": true,

  "$uid": {
    ".read": true,
    ".write": "auth !== null && auth.uid === $uid",
    ".indexOn": ["completed"]
  }
}

} }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/r-park/todo-react-redux/issues/70#issuecomment-313967572, or mute the thread https://github.com/notifications/unsubscribe-auth/AUN_jORq2_DBJLh0Qp81zD0fT41erDVJks5sMUoWgaJpZM4OQeVu .

KillerBee05 avatar Jul 09 '17 21:07 KillerBee05

seems its still having trouble pulling the record even with indexOn: ["title"] The error im getting in the dev console is that " Cannot read property 'title' of null"

image image

image

image

KillerBee05 avatar Jul 10 '17 03:07 KillerBee05

So I found that its pulling everyones data. But the record is 3 to 4 levels deep. Auth ID -> Record ID -> Data. Do you know of a way to loop twice through something within a render(){ I think it just needs to loop one more time?

image

KillerBee05 avatar Jul 18 '17 16:07 KillerBee05

+1 Were you ever able to do this? Where is that simulation results page?

Tzikas avatar Oct 12 '17 21:10 Tzikas

I"m running this

		ref.once('value', (snapshot) => {
			console.log(snapshot);
			console.log(snapshot.val());
                .... 

in the firebase-list.js file with the firebase rules changed to what's above, but I'm still getting only the tasks from the user logged in.

Tzikas avatar Oct 18 '17 11:10 Tzikas

I see I had to change taskList.path = '/all'; to taskList.path = '/tasks'; like @KillerBee05 . Where is this 'tasks' route decided?

Tzikas avatar Oct 18 '17 11:10 Tzikas

Ok nvm. I think I understand what is going on here. I'll post what I did incase it helps anyone else. I created a new collection on firebase after I added it to the rules, and then pushed the tasks to that

			firebaseDb.ref('/all')
			.push(value, error => error ? reject(error) : resolve());

and then i can decide what the path is.

export function loadAllTasks(){
	return (dispatch) => {
		taskList.path = '/all';
		console.log('load all')
		console.log(taskList)
	       	
		taskList.subscribe(dispatch);

	} 
	
}

Tzikas avatar Oct 18 '17 12:10 Tzikas