PFUsers are sharing all the same PFObjects?

34 views Asked by At

Below are images to explain;

User 1 Logs in and sees the following based on the [PFUser currentUser].username;

enter image description hereenter image description here

However, if I register a new account and login as User 2 the same data is shared, and the name is changed in accordance to the [PFUser currentUser].username;

enter image description here enter image description here

Im sure there is a method, but I'm not sure how exactly, on how do ensure any PFObjects being altered after logging in and securing a PFUser ID, are only associated with THAT user?

2

There are 2 answers

3
nathan On

It works as expected. You should store the image along with the user that uploaded it. The label Uploaded by: *username* should be built with "Uploaded by: " + photoUploader.username not "Uploaded by: " + PFUser.currentUser.username

0
FarisZ On

I was able to fix it by adding [query whereKey:@"user" equalTo:[PFUser currentUser]];

-(void)getReportImages{
//Fetch images
PFQuery *query = [PFQuery queryWithClassName:@"ReportImageObject"];

[query orderByDescending:KEY_CREATION_DATE];
[query whereKey:@"user" equalTo:[PFUser currentUser]];
[query findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {
    if (!error) {
        self.reportsObjectArray = nil;
        self.reportsObjectArray = [[NSArray alloc] initWithArray:objects];
        [self loadReportViews];
    } else {
        [self showErrorView:error];
    }
}];
}