Realm.Sync.User

Class for logging in and managing Sync users.

Realm.Sync.User.all
static

A dictionary containing users that are currently logged in. The keys in the dictionary are user identities, values are corresponding User objects.

Type:
object
Realm.Sync.User.current
static

Get the currently logged in user. Throws error if > 1 user logged in, returns undefined if no users logged in.

Type:
User
identity

Gets the identity of this user on the Realm Object Server. The identity is a guaranteed to be unique among all users on the Realm Object Server.

Type:
string
isAdmin

Returns true if this user is an administrator

Type:
bool
server

Gets the server URL that was used for authentication.

Type:
string
token

Gets this user's refresh token. This is the user's credential for accessing the Realm Object Server and should be treated as sensitive data.

Type:
string
Realm.Sync.User.adminUser(adminToken)User
static

Create an admin user for the given authentication server with an existing token

Parameters:
  • adminToken
    • Type: string
    • existing admin token

Returns: User
  • admin user populated with the given token and server
Realm.Sync.User.login(server, username, password, callback)
static

Login a sync user with username and password.

Parameters:
  • server
    • Type: string
    • authentication server

  • username
    • Type: string
  • password
    • Type: string
  • callback
    • Type: function
    • called with the following arguments:

      • error - an Error object is provided on failure
      • user - a valid User object on success
Realm.Sync.User.register(server, username, password, callback)
static

Register a sync user with username and password.

Parameters:
  • server
    • Type: string
    • authentication server

  • username
    • Type: string
  • password
    • Type: string
  • callback
    • Type: function
    • called with the following arguments:

      • error - an Error object is provided on failure
      • user - a valid User object on success
Realm.Sync.User.registerWithProvider(server, provider, providerToken, callback)
static

Login a sync user using an external login provider.

Parameters:
  • server
    • Type: string
    • authentication server

  • provider
    • Type: string
    • The provider type

  • providerToken
    • Type: string
    • The access token for the given provider

  • callback
    • Type: function
    • called with the following arguments:

      • error - an Error object is provided on failure
      • user - a valid User object on success
logout()

Logs out the user from the Realm Object Server.

openManagementRealm()Realm

Get the management realm for this User. This Realm can be used to control access and permissions for Realms owned by the user. This includes giving others access to the Realms.

Returns: Realm