ParseACL
public struct ParseACL: ParseType,
Decodable,
Equatable,
Hashable
extension ParseACL: CustomDebugStringConvertible
extension ParseACL: CustomStringConvertible
ParseACL
is used to control which users can access or modify a particular ParseObject
.
Each ParseObject
has its own ACL. You can grant read and write permissions separately
to specific users, to groups of users that belong to roles, or you can grant permissions to
“the public” so that, for example, any user could read a particular object but only a
particular set of users could write to that object.
-
An enum specifying read and write access controls.
See moreDeclaration
Swift
public enum Access : String, Codable, CodingKey
-
The default initializer.
Declaration
Swift
public init()
-
Controls whether the public is allowed to read this object.
Declaration
Swift
public var publicRead: Bool { get set }
-
Controls whether the public is allowed to write this object.
Declaration
Swift
public var publicWrite: Bool { get set }
-
Gets whether the given
objectId
is explicitly allowed to read this object. Even if this returnsfalse
, the user may still be able to access it ifpublicReadAccess
returnstrue
or if the user belongs to a role that has access.Declaration
Swift
public func getReadAccess(objectId: String) -> Bool
Parameters
objectId
The
ParseUser.objectId
of the user for which to retrieve access.Return Value
true
if the user with thisobjectId
has explicit read access, otherwisefalse
. -
Gets whether the given
ParseUser
is explicitly allowed to read this object. Even if this returnsfalse
, the user may still be able to access it ifpublicReadAccess
returnstrue
or if the user belongs to a role that has access.Declaration
Swift
public func getReadAccess<T>(user: T) -> Bool where T : ParseUser
Parameters
user
The
ParseUser
for which to retrieve access.Return Value
true
if the user with thisParseUser
has explicit read access, otherwisefalse
. -
Gets whether the given
objectId
is explicitly allowed to write this object. Even if this returns false, the user may still be able to write it ifpublicWriteAccess
returnstrue
or if the user belongs to a role that has access.Declaration
Swift
public func getWriteAccess(objectId: String) -> Bool
Parameters
objectId
The
ParseUser.objectId
of the user for which to retrieve access.Return Value
true
if the user with thisParseUser.objectId
has explicit write access, otherwisefalse
. -
Gets whether the given
ParseUser
is explicitly allowed to write this object. Even if this returns false, the user may still be able to write it ifpublicWriteAccess
returnstrue
or if the user belongs to a role that has access.Declaration
Swift
public func getWriteAccess<T>(user: T) -> Bool where T : ParseUser
Parameters
user
The
ParseUser
of the user for which to retrieve access.Return Value
true
if theParseUser
has explicit write access, otherwisefalse
. -
Set whether the given
objectId
is allowed to read this object.Declaration
Swift
public mutating func setReadAccess(objectId: String, value: Bool)
Parameters
value
Whether the given user can read this object.
objectId
The
ParseUser.objectId
of the user to assign access. -
Set whether the given
objectId
is allowed to write this object.Declaration
Swift
public mutating func setWriteAccess(objectId: String, value: Bool)
Parameters
value
Whether the given user can write this object.
objectId
The
ParseUser.objectId
of the user to assign access.
-
Get whether users belonging to the role with the given name are allowed to read this object. Even if this returns
false
, the role may still be able to read it if a parent role has read access.Declaration
Swift
public func getReadAccess(roleName: String) -> Bool
Parameters
roleName
The name of the role.
Return Value
true
if the role has read access, otherwisefalse
. -
Get whether users belonging to the role are allowed to read this object. Even if this returns
false
, the role may still be able to read it if a parent role has read access.Declaration
Swift
public func getReadAccess<T>(role: T) -> Bool where T : ParseRole
Parameters
role
The
ParseRole
to get access for.Return Value
true
if theParseRole
has read access, otherwisefalse
. -
Get whether users belonging to the role with the given name are allowed to write this object. Even if this returns
false
, the role may still be able to write it if a parent role has write access.Declaration
Swift
public func getWriteAccess(roleName: String) -> Bool
Parameters
roleName
The name of the role.
Return Value
true
if the role has read access, otherwisefalse
. -
Get whether users belonging to the role are allowed to write this object. Even if this returns
false
, the role may still be able to write it if a parent role has write access.Declaration
Swift
public func getWriteAccess<T>(role: T) -> Bool where T : ParseRole
Parameters
role
The
ParseRole
to get access for.Return Value
true
if the role has read access, otherwisefalse
. -
Set whether users belonging to the role with the given name are allowed to read this object.
Declaration
Swift
public mutating func setReadAccess(roleName: String, value: Bool)
Parameters
value
Whether the given role can read this object.
roleName
The name of the role.
-
Set whether users belonging to the role with the given name are allowed to write this object.
Declaration
Swift
public mutating func setWriteAccess(roleName: String, value: Bool)
Parameters
allowed
Whether the given role can write this object.
roleName
The name of the role.
-
Get the default ACL from the Keychain.
Declaration
Swift
public static func defaultACL() throws -> ParseACL
Return Value
Returns the default ACL.
-
Sets a default ACL that can later be used by
ParseObjects
.To apply the default ACL to all instances of a respective
ParseObject
when they are created, you will need to addACL = try? ParseACL.defaultACL()
. You can also at it when conforming toParseObject
:struct MyParseObject: ParseObject { var objectId: String? var createdAt: Date? var updatedAt: Date? var ACL: ParseACL? = try? ParseACL.defaultACL() }
This value will be copied and used as a template for the creation of new ACLs, so changes to the instance after this method has been called will not be reflected in new instance of
ParseObject
.- If
false
, the providedacl
will be used without modification. If
acl
isnil
, this value is ignored.
Declaration
Swift
public static func setDefaultACL(_ acl: ParseACL, withAccessForCurrentUser: Bool) throws -> ParseACL
Parameters
acl
The ACL to use as a template for instances of
ParseObject
.withAccessForCurrentUser
If
true
, theACL
that is applied to newly-created instance ofParseObject
will provide read and write access to theParseUser.+currentUser
at the time of creation.Return Value
Updated defaultACL
- If
-
Declaration
Swift
public init(from decoder: Decoder) throws
-
Declaration
Swift
public func encode(to encoder: Encoder) throws
-
Declaration
Swift
public var debugDescription: String { get }
-
Declaration
Swift
public var description: String { get }