Added option to include e-mail address in user rpc call.

This commit is contained in:
flash 2024-11-21 19:37:04 +00:00
parent 174ceaa4e7
commit 242e70eabf

View file

@ -19,7 +19,7 @@ final class UsersRpcHandler implements RpcHandler {
) {} ) {}
#[RpcQuery('misuzu:users:getUser')] #[RpcQuery('misuzu:users:getUser')]
public function queryGetUser(string $userId): array { public function queryGetUser(string $userId, bool $includeEMailAddress = false): array {
try { try {
$userInfo = $this->usersCtx->getUserInfo($userId, Users::GET_USER_ID); $userInfo = $this->usersCtx->getUserInfo($userId, Users::GET_USER_ID);
} catch(RuntimeException) { } catch(RuntimeException) {
@ -65,8 +65,11 @@ final class UsersRpcHandler implements RpcHandler {
'created_at' => $userInfo->getCreatedAt()->toIso8601ZuluString(), 'created_at' => $userInfo->getCreatedAt()->toIso8601ZuluString(),
]; ];
if($includeEMailAddress)
$output['email'] = $userInfo->getEMailAddress();
if($userInfo->hasLastActive()) if($userInfo->hasLastActive())
$output['last_active_at'] = $userInfo->getLastActiveAt()->toIso8601ZuluString(); $output['last_active_at'] = $userInfo->getLastActiveAt()->toIso8601ZuluString();
$roles = XArray::select( $roles = XArray::select(
$this->usersCtx->getRoles()->getRoles(userInfo: $userInfo, hasString: true, orderByRank: true), $this->usersCtx->getRoles()->getRoles(userInfo: $userInfo, hasString: true, orderByRank: true),