Table of Contents

Interface ICmsUser

Namespace
ToSic.Sxc.Context
Assembly
ToSic.Sxc.dll

The user context of your code - so it's information about the user your code is using.

[PublicApi]
public interface ICmsUser : IHasMetadata

Examples

🪒 In Dynamic Razor it's found on CmsContext.User
🪒 In Typed Razor it's found on MyUser

Remarks

History

  • v18 enhanced to serialize - so it can be returned by a WebApi Controller

Properties

Email

The user e-mail. If anonymous/not logged in, would be an empty string.

string Email { get; }

Property Value

string

Examples

🪒 Use in Dynamic Razor: CmsContext.User.Email
🪒 Use in Typed Razor: MyUser.Email

Remarks

History: Added in v.14.09

Id

User Id as int. Works in DNN and Oqtane.

int Id { get; }

Property Value

int

The ID or 0 (zero) if anonymous

Examples

🪒 Use in Dynamic Razor: CmsContext.User.UrlRoot
🪒 Use in Typed Razor: MyUser.Id

IsAnonymous

Information if the user is anonymous (not logged in)

bool IsAnonymous { get; }

Property Value

bool

Examples

🪒 Use in Dynamic Razor: CmsContext.User.IsAnonymous
🪒 Use in Typed Razor: MyUser.IsAnonymous

Remarks

History: This was added fairly late in v14.08

IsContentAdmin

Information if the current user is Site Content Administrator.

bool IsContentAdmin { get; }

Property Value

bool

Examples

🪒 Use in Dynamic Razor: CmsContext.User.IsContentAdmin
🪒 Use in Typed Razor: MyUser.IsContentAdmin

Remarks

Basically this means a user has Admin permissions, but may not have all admin permissions if excluded through special 2sxc-groups. These are not the highest possible privileges

  • For the site it would be IsSiteDeveloper
  • For the entire system that would be IsSystemAdmin.

History: New in 2sxc 14.09

IsSiteAdmin

Information if the current user is Site Administrator.

bool IsSiteAdmin { get; }

Property Value

bool

Examples

🪒 Use in Dynamic Razor: CmsContext.User.IsSiteAdmin
🪒 Use in Typed Razor: MyUser.IsSiteAdmin

Remarks

Basically this means a user has very high permissions - incl. the ability to create users in a site etc. But these are not the highest possible privileges

  • For the site it would be IsSiteDeveloper
  • For the entire system that would be IsSystemAdmin.

History: New in 2sxc 12

IsSiteDeveloper

Information if the current user is Developer on the current site.

bool IsSiteDeveloper { get; }

Property Value

bool

Examples

🪒 Use in Dynamic Razor: CmsContext.User.IsSiteDeveloper
🪒 Use in Typed Razor: MyUser.IsSiteDeveloper

Remarks

Basically this means a user has maximum site permissions - incl. the ability to install additional components or do dangerous things like edit razor. These are almost the highest possible privileges

  • For the entire system that would be IsSystemAdmin.

History: New in 2sxc 12

IsSystemAdmin

Information if the current user is System Administrator.

bool IsSystemAdmin { get; }

Property Value

bool

Examples

🪒 Use in Dynamic Razor: CmsContext.User.IsSystemAdmin
🪒 Use in Typed Razor: MyUser.IsSystemAdmin

Remarks

Basically this means a user has maximum permissions - incl. the ability to install additional components or do dangerous things like edit razor.

History: New in 2sxc 12

Metadata

Metadata of the current user

[JsonIgnore]
IMetadata Metadata { get; }

Property Value

IMetadata

Remarks

History: Added in v13.12

Name

The username as should be displayed.

string Name { get; }

Property Value

string

The name or an empty string if anonymous

Examples

🪒 Use in Dynamic Razor: CmsContext.User.Name
🪒 Use in Typed Razor: MyUser.Name

Remarks

History: Added in v.14.09

Username

The username used on the login.

string Username { get; }

Property Value

string

The username or an empty string if anonymous

Examples

🪒 Use in Dynamic Razor: CmsContext.User.Username
🪒 Use in Typed Razor: MyUser.Username

Remarks

History: Added in v.14.09