@@ -125,6 +125,36 @@ public extension ParseUser {
125125 }
126126 }
127127
128+ /**
129+ Logs in a `ParseUser` *asynchronously* with a given `objectId` allowing the impersonation of a User.
130+ On success, this saves the logged in `ParseUser`with this session to the keychain, so you can retrieve
131+ the currently logged in user using *current*.
132+
133+ - parameter objectId: The objectId of the user to login.
134+ - parameter options: A set of header options sent to the server. Defaults to an empty set.
135+ - returns: Returns the logged in `ParseUser`.
136+ - throws: An error of type `ParseError`.
137+ - important: The Parse Keychain currently only supports one(1) user at a time. This means
138+ if you use `loginAs()`, the current logged in user will be replaced. If you would like to revert
139+ back to the previous user, you should capture the `sesionToken` of the previous user before
140+ calling `loginAs()`. When you are ready to revert, 1) `logout()`, then `become()` with
141+ the sessionToken.
142+ - note: Calling this endpoint does not invoke session triggers such as beforeLogin and
143+ afterLogin. This action will always succeed if the supplied user exists in the database, regardless
144+ of whether the user is currently locked out.
145+ - note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer
146+ desires a different policy, it should be inserted in `options`.
147+ - requires: `.usePrimaryKey` has to be available. It is recommended to only
148+ use the primary key in server-side applications where the key is kept secure and not
149+ exposed to the public.
150+ */
151+ @discardableResult static func loginAs( objectId: String ,
152+ options: API . Options = [ ] ) async throws -> Self {
153+ try await withCheckedThrowingContinuation { continuation in
154+ Self . loginAs ( objectId: objectId, options: options, completion: continuation. resume)
155+ }
156+ }
157+
128158#if !os(Linux) && !os(Android) && !os(Windows)
129159 /**
130160 Logs in a `ParseUser` *asynchronously* using the session token from the Parse Objective-C SDK Keychain.
0 commit comments