Current User Context
# package-development
w
Is it just me or can anyone get the Global Context
UMB_CURRENT_USER_CONTEXT
@Markus Johansson @Kevin Jump ? I am not sure its exported from Umbraco or not, I can consume the context with the string underneath the TOKEN.
Copy code
typescript
// Can't do :(
this.consumeContext(UMB_CURRENT_USER_CONTEXT, (currentUserCtx) =>{
    console.log('currentUserCtx', currentUserCtx);
});

// Can do this - but no typings
this.consumeContext('UmbCurrentUserContext', (currentUserCtx) =>{
    console.log('currentUserCtx', currentUserCtx);
});
Curious if you have any thoughts at all @Jacob Overgaard ?
And to confuse you more - the alias that the Global Context for this is registered as is
Umb.GlobalContext.CurrentUser
so I assumed the underlying string for the TOKEN would be the same - but nope its
UmbCurrentUserContext
😛
OK ignore me - VSCode just didn't wanna be helfpul at all and find the TOKEN magically like it does normally and had to be explict with the import
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user';
j
Glad you figured it out 🙂
w
Just weird VSCode didn’t offer it up as a completion for me with other tokens.
m
Sorry for being “late to the train” here 😂 Happy you found a solution!
17 Views