From 5e3da1b512fea2148862f8d182b00560f344dbd8 Mon Sep 17 00:00:00 2001 From: Maciej Krajowski-Kukiel Date: Mon, 3 Nov 2025 12:06:39 +0100 Subject: [PATCH 1/7] Update README.md --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 404bc10..9a25f07 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ You can log the user in (which [creates a new session](https://documentation.pla function res = 'modules/user/commands/session/create', email: 'email@example.com', password: 'password' ``` -#### Accessing current profile +#### Accessing current profile in Pages To access information about the currently logged-in user, use the following command provided by the module: @@ -230,7 +230,60 @@ To access information about the currently logged-in user, use the following comm function profile = 'modules/user/helpers/current_profile' ``` -This command is implemented in `modules/user/public/lib/helpers/current_profile.liquid`. When you investigate the file, you'll notice that it not only loads the user's profile information from the database but also extends the profile's roles with either [authenticated](#authenticated-role) or [anonymous](#anonymous-role) if the user is not currently logged in. User object is also available under profile.user when the user is logged in. +This command is implemented in `modules/user/public/lib/helpers/current_profile.liquid`. When you investigate the file, you'll notice that it not only loads the user's profile information from the database but also extends the profile's roles with either [authenticated](#authenticated-role) or [anonymous](#anonymous-role) if the user is not currently logged in. The user object is also available under profile.user when the user is logged in. + +##### Current profile in Layouts + +In most applications, you will have a layout with a navigation bar, in which you will want to display a "log in" link for the not logged in user, or a list of links to which the currently logged in user has access. To avoid invoking `modules/user/helpers/current_profile` twice—once in a Page and once in a Layout —the helper uses the [export liquid tag](https://documentation.platformos.com/api-reference/liquid/platformos-tags#export) to make the current profile easily accessible via context.exports.current_profile ([see implementation](https://github.com/Platform-OS/pos-module-user/blob/master/modules/user/public/lib/helpers/current_profile.liquid#L15)). + +As a result, inside your app/views/layouts/application.liquid, you can have code like: + +```liquid +{% liquid + if context.current_user + assign current_profile = context.exports.current_profile + unless current_profile + function current_profile = 'modules/user/helpers/current_profile' + endunless + endif +%} +``` + +It will trigger `current_profile` helper only if it hasn't already been triggered in a Page. You could then build navigation and check permissions based on the current profile's roles as follows: + +```html +{% liquid + if context.current_user + assign current_profile = context.exports.current_profile + unless current_profile + function current_profile = 'modules/user/helpers/current_profile' + endunless + endif +%} + +``` + +And invoke `can_do` helpers to check if the currently logged-in user has permissions to view certain pages. #### Log out From 15b5bea2656a097204d3d6b7443391fef46a14d2 Mon Sep 17 00:00:00 2001 From: Maciej Krajowski-Kukiel Date: Mon, 3 Nov 2025 12:09:20 +0100 Subject: [PATCH 2/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a25f07..4aeed47 100644 --- a/README.md +++ b/README.md @@ -268,7 +268,7 @@ It will trigger `current_profile` helper only if it hasn't already been triggere
  • Welcome, {{ current_profile.email }}
  • {% function can_view_admin = 'modules/user/helpers/can_do', requester: current_profile, do: 'admin_pages.view' %} {% if can_view_admin %} -
  • Admin
  • +
  • Admin
  • {% endif %}
    From 4fb874cc08902abe1395560410ce6c55e1994997 Mon Sep 17 00:00:00 2001 From: Maciej Krajowski-Kukiel Date: Tue, 4 Nov 2025 08:57:35 +0100 Subject: [PATCH 3/7] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alex Pozsár <135258214+simplykatsa@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4aeed47..c45ebc3 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,7 @@ To access information about the currently logged-in user, use the following comm function profile = 'modules/user/helpers/current_profile' ``` -This command is implemented in `modules/user/public/lib/helpers/current_profile.liquid`. When you investigate the file, you'll notice that it not only loads the user's profile information from the database but also extends the profile's roles with either [authenticated](#authenticated-role) or [anonymous](#anonymous-role) if the user is not currently logged in. The user object is also available under profile.user when the user is logged in. +This command is implemented in `modules/user/public/lib/helpers/current_profile.liquid`. When you investigate the file, you'll notice that it not only loads the user's profile information from the database but also extends the profile's roles. If the user is logged in, the helper adds the [authenticated](#authenticated-role) role. If not, it adds the [anonymous](#anonymous-role) role instead. The user object is also available under profile.user when the user is logged in. ##### Current profile in Layouts From a11f29840223de445af1b9134a399d3910eabd6c Mon Sep 17 00:00:00 2001 From: Maciej Krajowski-Kukiel Date: Tue, 4 Nov 2025 08:57:47 +0100 Subject: [PATCH 4/7] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alex Pozsár <135258214+simplykatsa@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c45ebc3..d9fb2df 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,7 @@ This command is implemented in `modules/user/public/lib/helpers/current_profile. In most applications, you will have a layout with a navigation bar, in which you will want to display a "log in" link for the not logged in user, or a list of links to which the currently logged in user has access. To avoid invoking `modules/user/helpers/current_profile` twice—once in a Page and once in a Layout —the helper uses the [export liquid tag](https://documentation.platformos.com/api-reference/liquid/platformos-tags#export) to make the current profile easily accessible via context.exports.current_profile ([see implementation](https://github.com/Platform-OS/pos-module-user/blob/master/modules/user/public/lib/helpers/current_profile.liquid#L15)). -As a result, inside your app/views/layouts/application.liquid, you can have code like: +As a result, you can include logic like the following in your `app/views/layouts/application.liquid` file: ```liquid {% liquid From 688e23212583586d2564efd6ba3922c76a0d2b7d Mon Sep 17 00:00:00 2001 From: Maciej Krajowski-Kukiel Date: Tue, 4 Nov 2025 08:57:53 +0100 Subject: [PATCH 5/7] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alex Pozsár <135258214+simplykatsa@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d9fb2df..11103a5 100644 --- a/README.md +++ b/README.md @@ -249,7 +249,7 @@ As a result, you can include logic like the following in your `app/views/layouts %} ``` -It will trigger `current_profile` helper only if it hasn't already been triggered in a Page. You could then build navigation and check permissions based on the current profile's roles as follows: +It triggers the `current_profile` helper only if it hasn't already been triggered in a Page. You can then build the navigation and check permissions based on the current profile's roles as follows: ```html {% liquid From 05daff0b5064fcaf17c7d1256200a0ff7995bdfa Mon Sep 17 00:00:00 2001 From: Maciej Krajowski-Kukiel Date: Tue, 4 Nov 2025 08:57:58 +0100 Subject: [PATCH 6/7] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alex Pozsár <135258214+simplykatsa@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 11103a5..3e8a96d 100644 --- a/README.md +++ b/README.md @@ -283,7 +283,7 @@ It triggers the `current_profile` helper only if it hasn't already been triggere ``` -And invoke `can_do` helpers to check if the currently logged-in user has permissions to view certain pages. +You can use the `can_do` helper to check if the currently logged-in user has permission to view certain pages. #### Log out From f7f7b40d8f7ab36b306ea9d522faedf968e29a07 Mon Sep 17 00:00:00 2001 From: Maciej Krajowski-Kukiel Date: Tue, 4 Nov 2025 08:58:08 +0100 Subject: [PATCH 7/7] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alex Pozsár <135258214+simplykatsa@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e8a96d..ecf3089 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,7 @@ This command is implemented in `modules/user/public/lib/helpers/current_profile. ##### Current profile in Layouts -In most applications, you will have a layout with a navigation bar, in which you will want to display a "log in" link for the not logged in user, or a list of links to which the currently logged in user has access. To avoid invoking `modules/user/helpers/current_profile` twice—once in a Page and once in a Layout —the helper uses the [export liquid tag](https://documentation.platformos.com/api-reference/liquid/platformos-tags#export) to make the current profile easily accessible via context.exports.current_profile ([see implementation](https://github.com/Platform-OS/pos-module-user/blob/master/modules/user/public/lib/helpers/current_profile.liquid#L15)). +In most applications, you will have a layout with a navigation bar, where you might want to display different links depending on the user's state - for example, a “Log in” link for unauthenticated users, or a list of user-specific links for logged-in users. To avoid invoking `modules/user/helpers/current_profile` twice — once in a Page and once in a Layout — the helper uses the [export Liquid tag](https://documentation.platformos.com/api-reference/liquid/platformos-tags#export). This tag makes the current profile easily accessible via context.exports.current_profile ([see implementation](https://github.com/Platform-OS/pos-module-user/blob/master/modules/user/public/lib/helpers/current_profile.liquid#L15)). As a result, you can include logic like the following in your `app/views/layouts/application.liquid` file: