Enable _adminUser in RN debug context
This commit is contained in:
parent
20defad505
commit
3b00719aaa
|
@ -72,6 +72,12 @@ export function createUser(args) {
|
|||
return deserialize(undefined, result);
|
||||
}
|
||||
|
||||
export function _adminUser(args) {
|
||||
args = args.map((arg) => serialize(null, arg));
|
||||
const result = sendRequest('_adminUser', {arguments: args});
|
||||
return deserialize(undefined, result);
|
||||
}
|
||||
|
||||
export function callMethod(realmId, id, name, args) {
|
||||
if (args) {
|
||||
args = args.map((arg) => serialize(realmId, arg));
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import { createUser as createUserRPC, getAllUsers as getAllUsersRPC } from './rpc';
|
||||
import { createUser as createUserRPC, _adminUser as _adminUserRPC, getAllUsers as getAllUsersRPC } from './rpc';
|
||||
import { keys, objectTypes } from './constants';
|
||||
import { createMethods } from './util';
|
||||
|
||||
|
@ -28,6 +28,10 @@ export default class User {
|
|||
return createUserRPC(Array.from(arguments));
|
||||
}
|
||||
|
||||
static _adminUser(adminToken, server) {
|
||||
return _adminUserRPC(Array.from(arguments));
|
||||
}
|
||||
|
||||
static get all() {
|
||||
return getAllUsersRPC();
|
||||
}
|
||||
|
|
21
src/rpc.cpp
21
src/rpc.cpp
|
@ -160,6 +160,27 @@ RPCServer::RPCServer() {
|
|||
JSObjectRef user_object = (JSObjectRef)jsc::Function::call(m_context, create_user_method, arg_count, arg_values);
|
||||
return (json){{"result", serialize_json_value(user_object)}};
|
||||
};
|
||||
m_requests["/_adminUser"] = [this](const json dict) {
|
||||
JSObjectRef realm_constructor = m_session_id ? JSObjectRef(m_objects[m_session_id]) : NULL;
|
||||
if (!realm_constructor) {
|
||||
throw std::runtime_error("Realm constructor not found!");
|
||||
}
|
||||
|
||||
JSObjectRef sync_constructor = (JSObjectRef)jsc::Object::get_property(m_context, realm_constructor, "Sync");
|
||||
JSObjectRef user_constructor = (JSObjectRef)jsc::Object::get_property(m_context, sync_constructor, "User");
|
||||
JSObjectRef create_user_method = (JSObjectRef)jsc::Object::get_property(m_context, user_constructor, "_adminUser");
|
||||
|
||||
json::array_t args = dict["arguments"];
|
||||
size_t arg_count = args.size();
|
||||
JSValueRef arg_values[arg_count];
|
||||
|
||||
for (size_t i = 0; i < arg_count; i++) {
|
||||
arg_values[i] = deserialize_json_value(args[i]);
|
||||
}
|
||||
|
||||
JSObjectRef user_object = (JSObjectRef)jsc::Function::call(m_context, create_user_method, arg_count, arg_values);
|
||||
return (json){{"result", serialize_json_value(user_object)}};
|
||||
};
|
||||
m_requests["/call_method"] = [this](const json dict) {
|
||||
JSObjectRef object = m_objects[dict["id"].get<RPCObjectID>()];
|
||||
std::string method_string = dict["name"].get<std::string>();
|
||||
|
|
Loading…
Reference in New Issue