<p>Solved! This appeared to be a Dynamic Subfolder Paths issue</p>
<p>if you replace {{ currentUser.id }} with {{id}} then user is able to login and logout using sso after saving assets.</p>

CC BY-SA 4.0
2022-04-08T21:02:37.523Z
2022-04-08T21:02:37.523Z
Jwurd
<p>Having tested this error only occurs while using the SAML Service provider plugin: I have tested in multiple versioning env and experienced the same issue.</p>
<p>I can save an asset file Image or doc while logged in the first time but if I log back in into via screen displays a server error and receive the below stack trace.
If I remove the asset file I am able to use SSO login again.</p>
<p><strong>Current ENV:</strong>
Craft Pro 3.7.38
Yii 2.0.45
Twig 2.14.13
SAML Service Provider 2.7.3</p>
<p><strong>Stack Trace</strong></p>
<pre><code>Next craft\errors\InvalidSubpathException: The Directory Photo field’s Asset Location setting has an invalid subpath (“profile/{{currentUser.id}}”). in /home/umhbweb/craft/vendor/craftcms/cms/src/fields/Assets.php:929
Stack trace:
#0 /home/umhbweb/craft/vendor/craftcms/cms/src/fields/Assets.php(501): craft\fields\Assets-&gt;_determineUploadFolderId()
#1 /home/umhbweb/craft/vendor/craftcms/cms/src/fields/Assets.php(565): craft\fields\Assets-&gt;craft\fields\{closure}()
#2 /home/umhbweb/craft/vendor/craftcms/cms/src/base/Element.php(4142): craft\fields\Assets-&gt;afterElementSave()
#3 /home/umhbweb/craft/vendor/craftcms/cms/src/elements/User.php(1617): craft\base\Element-&gt;afterSave()
#4 /home/umhbweb/craft/vendor/craftcms/cms/src/services/Elements.php(2703): craft\elements\User-&gt;afterSave()
#5 /home/umhbweb/craft/vendor/craftcms/cms/src/services/Elements.php(784): craft\services\Elements-&gt;_saveElementInternal()
#6 /home/umhbweb/craft/vendor/flipboxfactory/saml-sp/src/services/login/User.php(168): craft\services\Elements-&gt;saveElement()
#7 /home/umhbweb/craft/vendor/flipboxfactory/saml-sp/src/services/login/User.php(145): flipbox\saml\sp\services\login\User-&gt;save()
#8 /home/umhbweb/craft/vendor/flipboxfactory/saml-sp/src/services/Login.php(68): flipbox\saml\sp\services\login\User-&gt;sync()
#9 /home/umhbweb/craft/vendor/flipboxfactory/saml-sp/src/controllers/LoginController.php(118): flipbox\saml\sp\services\Login-&gt;transformToUser()
#10 [internal function]: flipbox\saml\sp\controllers\LoginController-&gt;actionIndex()
#11 /home/umhbweb/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#12 /home/umhbweb/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction-&gt;runWithParams()
#13 /home/umhbweb/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller-&gt;runAction()
#14 /home/umhbweb/craft/vendor/craftcms/cms/src/web/Application.php(293): yii\base\Module-&gt;runAction()
#15 /home/umhbweb/craft/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application-&gt;runAction()
#16 /home/umhbweb/craft/vendor/craftcms/cms/src/web/Application.php(278): yii\web\Application-&gt;handleRequest()
#17 /home/umhbweb/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application-&gt;handleRequest()
#18 /home/umhbweb/craft/web/index.php(12): yii\base\Application-&gt;run()
#19 {main}
</code></pre>

<craft3><plugin-development>
User profile - if user logs out after saving an Asset - Invalid subpath “profile/{{currentUser.id}}” - SSO Login fails
# User profile - if user logs out after saving an Asset - Invalid subpath “profile/{{currentUser.id}}” - SSO Login fails

(Asked by: username_0 on 2022-04-08)

Having tested this error only occurs while using the SAML Service provider plugin: I have tested in multiple versioning env and experienced the same issue.
I can save an asset file Image or doc while logged in the first time but if I log back in into via screen displays a server error and receive the below stack trace.
If I remove the asset file I am able to use SSO login again.
Current ENV:
Craft Pro 3.7.38
Yii 2.0.45
Twig 2.14.13
SAML Service Provider 2.7.3
Stack Trace
Next craft\errors\InvalidSubpathException: The Directory Photo field’s Asset Location setting has an invalid subpath (“profile/{{currentUser.id}}”). in /home/umhbweb/craft/vendor/craftcms/cms/src/fields/Assets.php:929
Stack trace:
#0 /home/umhbweb/craft/vendor/craftcms/cms/src/fields/Assets.php(501): craft\fields\Assets->_determineUploadFolderId()
#1 /home/umhbweb/craft/vendor/craftcms/cms/src/fields/Assets.php(565): craft\fields\Assets->craft\fields\{closure}()
#2 /home/umhbweb/craft/vendor/craftcms/cms/src/base/Element.php(4142): craft\fields\Assets->afterElementSave()
#3 /home/umhbweb/craft/vendor/craftcms/cms/src/elements/User.php(1617): craft\base\Element->afterSave()
#4 /home/umhbweb/craft/vendor/craftcms/cms/src/services/Elements.php(2703): craft\elements\User->afterSave()
#5 /home/umhbweb/craft/vendor/craftcms/cms/src/services/Elements.php(784): craft\services\Elements->_saveElementInternal()
#6 /home/umhbweb/craft/vendor/flipboxfactory/saml-sp/src/services/login/User.php(168): craft\services\Elements->saveElement()
#7 /home/umhbweb/craft/vendor/flipboxfactory/saml-sp/src/services/login/User.php(145): flipbox\saml\sp\services\login\User->save()
#8 /home/umhbweb/craft/vendor/flipboxfactory/saml-sp/src/services/Login.php(68): flipbox\saml\sp\services\login\User->sync()
#9 /home/umhbweb/craft/vendor/flipboxfactory/saml-sp/src/controllers/LoginController.php(118): flipbox\saml\sp\services\Login->transformToUser()
#10 [internal function]: flipbox\saml\sp\controllers\LoginController->actionIndex()
#11 /home/umhbweb/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#12 /home/umhbweb/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#13 /home/umhbweb/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#14 /home/umhbweb/craft/vendor/craftcms/cms/src/web/Application.php(293): yii\base\Module->runAction()
#15 /home/umhbweb/craft/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction()
#16 /home/umhbweb/craft/vendor/craftcms/cms/src/web/Application.php(278): yii\web\Application->handleRequest()
#17 /home/umhbweb/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#18 /home/umhbweb/craft/web/index.php(12): yii\base\Application->run()
#19 {main}

**Tags:** craft3, plugin-development


---

## 1 answers

### Answer by username_1 on 2022-04-08. Score: 2

Solved! This appeared to be a Dynamic Subfolder Paths issue

if you replace {{ currentUser.id }} with {{id}} then user is able to login and logout using sso after saving assets.


---

