diff --git a/definitions/UserDefinitions.php b/definitions/UserDefinitions.php index e2bbe10..b08cd4c 100644 --- a/definitions/UserDefinitions.php +++ b/definitions/UserDefinitions.php @@ -16,6 +16,7 @@ use humhub\modules\user\models\Group; use humhub\modules\user\models\Session; use humhub\modules\user\models\User; +use yii\helpers\ArrayHelper; use yii\helpers\Url; /** @@ -41,14 +42,26 @@ public static function getUser(User $user) 'display_name' => $user->displayName, 'url' => Url::to(['/', 'container' => $user], true), 'account' => static::getAccount($user), - 'profile' => static::getProfile($user->profile), + 'profile' => static::getProfile($user), ]; } - public static function getProfile(Profile $profile) + public static function getProfile(User $user) { - $attributes = $profile->attributes; - unset($attributes['user_id']); + $attributes = $user->profile->attributes; + ArrayHelper::remove($attributes, 'user_id'); + + ArrayHelper::setValue( + $attributes, + 'image_url', + Url::to($user->profileImage->getUrl(), true), + ); + ArrayHelper::setValue( + $attributes, + 'banner_url', + Url::to($user->profileBannerImage->getUrl(), true), + ); + return $attributes; } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index df5e298..f838ef9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -3,6 +3,7 @@ Changelog 0.10.4 (Unreleased) --------------------------- +- Enh #181: Added user profile `image_url` and `banner_url` - Enh #179: Added new `resend` and `cancel` endpoints for user invite 0.10.3 (September 13, 2024) diff --git a/docs/html/auth.html b/docs/html/auth.html index e89e486..0d1668c 100644 --- a/docs/html/auth.html +++ b/docs/html/auth.html @@ -387,7 +387,7 @@
{- "username": "username@example.com",
- "password": "password"
}
{- "code": 200,
- "message": "string",
- "auth_token": "eyJ0eXAiOiJKV1QiLC .... tE_7_rLSX3vA",
- "expired_at": "string"
}
{- "id": 14,
- "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
- "display_name": "John Doe",
- "account": {
- "id": 14,
- "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
- "username": "john.doe",
- "email": "john.doe@example.com",
- "visibility": 0,
- "status": 1,
- "tags": [
- "Administration",
- "Support",
- "HumHub"
], - "language": "DE",
- "time_zone": "Europe/Paris",
- "contentcontainer_id": 5,
- "authclient": "local",
- "authclient_id": "0123456789",
- "last_login": "2023-09-11 08:46:40"
}, - "profile": {
- "firstname": "John",
- "lastname": "Doe",
- "title": "Test user",
- "gender": "male",
- "street": "New Street 5",
- "zip": 80331,
- "city": "Munich",
- "country": "DE (ISO 3166 code)",
- "state": "string",
- "birthday_hide_year": 0,
- "birthday": "1990-01-01",
- "about": "string",
- "phone_private": "string",
- "phone_work": "string",
- "mobile": "string",
- "fax": "string",
- "im_skype": "string",
- "im_xmpp": "string",
- "url": "string",
- "url_facebook": "string",
- "url_linkedin": "string",
- "url_xing": "string",
- "url_youtube": "string",
- "url_vimeo": "string",
- "url_flickr": "string",
- "url_myspace": "string",
- "url_twitter": "string"
}
}
{- "id": 14,
- "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
- "display_name": "John Doe",
- "account": {
- "id": 14,
- "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
- "username": "john.doe",
- "email": "john.doe@example.com",
- "visibility": 0,
- "status": 1,
- "tags": [
- "Administration",
- "Support",
- "HumHub"
], - "language": "DE",
- "time_zone": "Europe/Paris",
- "contentcontainer_id": 5,
- "authclient": "local",
- "authclient_id": "0123456789",
- "last_login": "2023-09-11 08:46:40"
}, - "profile": {
- "firstname": "John",
- "lastname": "Doe",
- "title": "Test user",
- "gender": "male",
- "street": "New Street 5",
- "zip": 80331,
- "city": "Munich",
- "country": "DE (ISO 3166 code)",
- "state": "string",
- "birthday_hide_year": 0,
- "birthday": "1990-01-01",
- "about": "string",
- "phone_private": "string",
- "phone_work": "string",
- "mobile": "string",
- "fax": "string",
- "im_skype": "string",
- "im_xmpp": "string",
- "url": "string",
- "url_facebook": "string",
- "url_linkedin": "string",
- "url_xing": "string",
- "url_youtube": "string",
- "url_vimeo": "string",
- "url_flickr": "string",
- "url_myspace": "string",
- "url_twitter": "string",
- "image_url": "string",
- "banner_url": "string"
}
}
id of user to Impersonate
userId required | integer id of user to Impersonate |
{- "userId": 1
}
{- "token": "impersonated-YvyEVcbzCvg0wLjb9yXylj1bkbotlCwkKjNKTZD9xMO86o1G-V9p-wklm5pUdXhdkSGj5dk-l",
- "expires": 1681671865
}