Click or drag to resize

IUserModules Property

Indicates the modules access of the user.

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
IModulesAccess Modules { get; }

Property Value

Type: IModulesAccess
Examples

This example looks if the user in the context can access the `home` module.

using system;
using AskiaPortalCmn;

namespace MyApp 
{
    class Program
    {
         static void Main(string[] args)
         {
                var context = ContextFactory.CreateByLoginAndPassword("login", "secret");
                var contextValidation = context.Validate();
                if (!contextValidation.Success)
                {
                    Console.Error.Write(contextValidation.Exception.Message);
                    return;
                }

                Guid homeModuleGuid = Guid.Parse("9821219b-0768-41cc-81d8-cf3b1ade9317");
                if (context.User.Modules.CanAccess(homeModuleGuid))
                {
                    Console.WriteLine("You're allowed to access the `Home` module!");
                }
                else
                {
                    Console.WriteLine("You're NOT allowed to access the `Home` module!");
                }
         }
    }
}
See Also