|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
The signed-in user's verified identity, readable outside a dispatch. More...
#include <session.hpp>
Public Member Functions | |
| bool | hasRole (std::string_view role) const |
Returns true if roles contains role. | |
Public Attributes | |
| std::string | id |
| Verified identity (e.g. username), as returned by the server. Empty if signed out. | |
| std::vector< std::string > | roles |
| Coarse-grained roles the app can gate UI on (e.g. "editor", "admin"). | |
| std::unordered_map< std::string, std::string > | claims |
| Free-form bag of string→string claims beyond id/roles. | |
The signed-in user's verified identity, readable outside a dispatch.
Context::principal only exists during a dispatch — session::current() returns nullptr outside one, so UI code (a button's enabled state, a menu item's visibility) has no way to ask "who is signed in and what may they do?" without attempting the action and catching the failure. Principal is the longer-lived counterpart an application installs once, typically right after a successful login dispatch, and reads from UI code to shape itself instead: bridge.currentPrincipal().hasRole("editor").
Deliberately not a process-wide global: the caller installs it on the specific Bridge (or other session-scoped object) whose backend it came from — see Bridge::setPrincipal/Bridge::currentPrincipal (core/bridge.hpp) — rather than one ambient value shared by every backend a process happens to hold.
Definition at line 78 of file session.hpp.
|
inlinenodiscard |
Returns true if roles contains role.
| role | Role name to look for. |
role is present in roles. Definition at line 91 of file session.hpp.
| std::string morph::session::Principal::id |
Verified identity (e.g. username), as returned by the server. Empty if signed out.
Definition at line 80 of file session.hpp.
| std::vector<std::string> morph::session::Principal::roles |
Coarse-grained roles the app can gate UI on (e.g. "editor", "admin").
Definition at line 83 of file session.hpp.
| std::unordered_map<std::string, std::string> morph::session::Principal::claims |
Free-form bag of string→string claims beyond id/roles.
Definition at line 86 of file session.hpp.