realm / realm-object-server

Tracking of issues related to the Realm Object Server and other general issues not related to the specific SDK's
https://realm.io
293 stars 42 forks source link

SyncUser.current! = Printing description of user: <uninitialized> #319

Closed doswelleth-zz closed 6 years ago

doswelleth-zz commented 6 years ago

Goals

Log into Realm Object Server client-side (Xcode) and the Realm Studio remotely

Expected Results

Log into app with a familiar implementation and the studio remotely having created an admin user

Actual Results

lldb Printing description of user: <uninitialized>

Steps to Reproduce

// Default Sync File

 let host = "<IPAddress>"

// Constants File

struct Constants {
static let defaultSyncHost                      = DefaultSync().host
static let syncAuthURL                          = URL(string: "http://\(defaultSyncHost):9080")!
static let syncServerURL                        = URL(string: "realm://\(defaultSyncHost):9080/")

// Endpoints
static let homeURL                                 = URL(string: "realm://\(defaultSyncHost):9080/home")!
}

// Configuration - Still in Constants file where Home is my model object

func homeConfig(user: SyncUser) -> Realm.Configuration  {
let config = Realm.Configuration(syncConfiguration: SyncConfiguration(user: SyncUser.current!,       realmURL: Constants.homeURL), objectTypes: [Home.self])
Permissions().home()
return config
}

// Permissions File

struct Permissions {
func home() {
    let user = SyncUser.current!
    let permission = SyncPermissionValue(realmPath: "/home", userID: "*", accessLevel: .write)
    user.applyPermission(permission) { error in
        if let error = error { print(error.localizedDescription); return }
    }
}

// Logging into my **Login View Controller** in viewDidLoad

 if (SyncUser.current != nil) {
            DispatchQueue.main.async {
                Realm.Configuration.defaultConfiguration = homeConfig(user: SyncUser.current!)
                self.login()
            }
        } else {
            self.presentAlert()
        }

// Finally, accessing the realm in my **Home View Controller**

  self.realm = try! Realm(configuration: homeConfig(user: SyncUser.current!))
  self.items = self.realm.objects(Home.self).sorted(byKeyPath: "created", ascending: false)

Version of Realm and Tooling

nirinchev commented 6 years ago

Issue moved to realm/realm-cocoa #5537 as this appears to be unrelated to ROS itself.