Skip to content

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

Closed

Description

@mogsten

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

Activity

  1. drew-gross commented on Mar 31, 2016

    @drew-gross
    Contributor

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

  2. mogsten commented on Mar 31, 2016

    @mogsten
    Author

    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"] = "user@rootorboot.com"
                    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

  3. flovilmart commented on Mar 31, 2016

    @flovilmart
    Contributor

    Can you please post the faulty schema?

  4. mogsten commented on Apr 1, 2016

    @mogsten
    Author

    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"
    }

  5. flovilmart commented on Apr 1, 2016

    @flovilmart
    Contributor

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

  6. mogsten commented on Apr 1, 2016

    @mogsten
    Author

    OK how would I be able to change that?

  7. hramos commented on Apr 1, 2016

    @hramos
    Contributor

    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.

  8. mogsten commented on Apr 1, 2016

    @mogsten
    Author

    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

  9. hramos commented on Apr 2, 2016

    @hramos
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions