Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have to remove contents of SCHEMA class before allowing user to Login - Happens for every user #1289

Closed
mogsten opened this issue Mar 31, 2016 · 9 comments

Comments

@mogsten
Copy link

mogsten commented Mar 31, 2016

I have to remove the Contents of the SCHEMA class every time before a user logs in, what could be causing this and would I be able to fix this?

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

Environment Setup

Parse Server 2.2.0 & MongoDB Running on Digital Ocean $5/month VPS

Steps to reproduce

Checked Xcode Console, Checked Previous Issues, found potential resolution, tried, Have to repeat process for every single user

Logs/Trace

@drew-gross
Copy link
Contributor

Can you please post some code that demonstrates what you are doing, what you expected to happen, and what actually happened?

@mogsten
Copy link
Author

mogsten commented Mar 31, 2016

Here is the Login Code in Xcode, this is what happens

PFFacebookUtils.logInInBackgroundWithReadPermissions(["public_profile", "user_birthday", "email"], block: {
user, error in
JTProgressHUD.showWithStyle(JTProgressHUDStyle.Gradient)

        if user == nil {
            print("Error Logging In")
            JTProgressHUD.hideWithTransition(.Default)
        }
        if user != nil {
            print("User signed up and logged in through Facebook!")
            JTProgressHUD.showWithStyle(JTProgressHUDStyle.Gradient)

            let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/?fields=picture.height(512).width(512),first_name,birthday,gender,bio,email", parameters: nil)
            graphRequest.startWithCompletionHandler({
                connection, result, error in
                print("ERROR: \(error)")


                guard let r = result as? NSDictionary else {
                    if let error = error {
                        print(error)
                    }
                    return
                }

                print(connection)
                print(result)


                if let e = error { print(e) }
                user!["firstName"] = r["first_name"]
                user!["gender"] = r["gender"]
                user!["pictureString"] = ((r["picture"] as! NSDictionary)["data"] as! NSDictionary) ["url"]
                //BIO
                user!["bio"] = "Thanks for Downloading Root or Boot, Please Enter a Bio by Clicking Here"

                if (r["bio"] != nil){
                    user!["bio"] = r["bio"]
                }

                user!["email"] = "[email protected]"
                if (r["email"] != nil) {
                    user!["email"] = r["email"]
                }

                //                    let locationObj = r.objectForKey("hometown")x
                //                    let location = locationObj!.objectForKey("name") as! String
                //                    print("Location: \(location)")

                //                    let workObj = r.objectForKey("work")
                //                    let workDescription = workObj?.objectForInfoDictionaryKey("description") as! String
                //                    print("Work Description: \(workDescription)")


                var ageDate = NSDate()
                var ageString = NSString()


                var dateFormatter = NSDateFormatter()
                dateFormatter.dateFormat = "MM/dd/yyyy"
                if (r["birthday"] != nil) {
                    ageDate = dateFormatter.dateFromString(r["birthday"] as! String)!
                    print(ageDate)
                }
                else {
                    ageDate = dateFormatter.dateFromString("01/01/2003")!
                    print(ageDate)
                }
                let ageDateFormatter = NSDateFormatter()
                ageDateFormatter.dateFormat = "MM/dd/yyyy"
                print(ageDateFormatter.stringFromDate(ageDate))
                ageString = ageDateFormatter.stringFromDate(ageDate)

                print("AGE STRING: \(ageString)")


                let pictureURL = ((r["picture"] as! NSDictionary)["data"] as! NSDictionary) ["url"] as! String
                let url = NSURL(string: pictureURL)
                let request = NSURLRequest(URL: url!)
                NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: {
                    response, data, error in
                    //                        print(ageDate as! String)

                    if let ageDateForKey = ageString as? String {

                        let birthday: NSDate = dateFormatter.dateFromString(ageDateForKey as String)!
                        var now: NSDate = NSDate()

                        var ageComponents: NSDateComponents = NSCalendar.currentCalendar().components(.Year, fromDate: birthday, toDate: now, options: [])
                        var age: Int = ageComponents.year
                        user!["age"] = 13

                        if (user!["age"] != nil) {
                            user!["age"] = age
                            print(age)
                        }
                        else if (user!["age"] == nil) {
                            user!["age"] = 13
                            print(age)
                        }

                    }

let imageFile = PFFile(name: "avatar.jpg", data: data!)
user!["picture"] = imageFile
user!.saveInBackgroundWithBlock(nil)

When I log in (Before SCHEMA fix) - Error Logging In
When I log in (After SCHEMA fix) - User logs in - print(results) runs

@flovilmart
Copy link
Contributor

Can you please post the faulty schema?

@mogsten
Copy link
Author

mogsten commented Apr 1, 2016

Here is the SCHEMA for the User which is what I am trying to create

{
"_id": "_User",
"authData": "map",
"age": "number",
"bio": "string",
"gender": "string",
"firstName": "string",
"email": "string",
"picture": "file",
"pictureString": "string",
"userAction": "string",
"Location": "geopoint",
"_metadata": {
"class_permissions": {
"get": {},
"find": {},
"update": {},
"create": {},
"delete": {},
"addField": {},
"readUserFields": [],
"writeUserFields": []
}
},
"username": "string",
"emailVerified": "boolean"
}

@flovilmart
Copy link
Contributor

You have Class Level permissions set on your schema that lock down the ability to modify, query or do anything

@mogsten
Copy link
Author

mogsten commented Apr 1, 2016

OK how would I be able to change that?

@hramos
Copy link
Contributor

hramos commented Apr 1, 2016

I am not sure how you originally got into this state, where the CLPs for the User class got completely locked down, but you can edit CLPs by using Parse Dashboard.

I would advise looking into how you got into this state in the first place, as you will want to make sure the CLPs don't get reset back to the locked down state unintentionally next time you deploy the server.

@hramos hramos closed this as completed Apr 1, 2016
@mogsten
Copy link
Author

mogsten commented Apr 1, 2016

Still I'm not too sure how to change it even through Parse Dashboard is there any code I am able to change and i just built the database 5 days ago and set up a parse server. Nothing else

@hramos
Copy link
Contributor

hramos commented Apr 2, 2016

You may use Server Fault for questions about managing Parse Server.

For code-level and/or implementation-related questions or technical support, please refer to Stack Overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants