private void InitPage() { Init(); #region << Init Roles >> var roles = new SecurityManager().GetAllRoles().OrderBy(x => x.Name).ToList(); foreach (var role in roles) { RoleOptions.Add(new SelectOption() { Value = role.Id.ToString(), Label = role.Name }); } #endregion #region << Actions >> HeaderActions.AddRange(new List <string>() { $"<button type='button' onclick='ErpEvent.DISPATCH(\"WebVella.Erp.Web.Components.PcForm\",\"submit\")' class='btn btn-green btn-sm'><span class='fa fa-save go-white'></span> Create App</button>", $"<a href='{ReturnUrl}' class='btn btn-white btn-sm'>Cancel</a>" }); #endregion }
private void InitPage() { var roles = new EqlCommand("select * from role").Execute(); foreach (var role in roles) { if ((string)role["name"] != "guest") { RoleOptions.Add(new SelectOption() { Value = role["id"].ToString(), Label = role["name"].ToString() }); } } RoleOptions = RoleOptions.OrderBy(x => x.Label).ToList(); if (RecordId != null) { var resultRecords = new EqlCommand($"select *,$user_role.id from user where id = '{RecordId}'").Execute(); if (resultRecords.Any()) { UserRecord = resultRecords.First(); } } if (String.IsNullOrWhiteSpace(ReturnUrl)) { ReturnUrl = "/sdk/access/user/l/list"; } }
private IRole CreateNewRole(RoleOptions roleOption) { IRole role; if (roleOption.AwsPolicies?.Any() == true || roleOption.CustomPolicies?.Any() == true || roleOption.InlinePolicies?.Any() == true) { var awsPolicies = roleOption.AwsPolicies?.Select(x => AwsCdkHandler.LocateAwsManagedPolicyByName(x)).ToList(); var customPolicies = roleOption.CustomPolicies?.Select(x => AwsCdkHandler.LocateManagedPolicyByName(x)).ToList(); var inlinePolicies = roleOption.InlinePolicies?.ToDictionary(policyId => policyId, policyId => LocatePolicyDocument(policyId, $"The PolicyDocument {policyId} of the role {roleOption.Name} was not found")); var policies = new List <IManagedPolicy>(); if (awsPolicies?.Any() == true) { policies.AddRange(awsPolicies); } if (customPolicies?.Any() == true) { policies.AddRange(customPolicies); } role = AwsCdkHandler.AddRole(roleOption.Name, AwsCdkHandler.CreateRoleProperties(roleOption.Name, roleOption.AssumedBy.ToArray(), policies.ToArray(), inlinePolicies)); } else if (roleOption.AwsActions?.Any() == true) { role = AwsCdkHandler.AddRole(roleOption.Name, AwsCdkHandler.CreateRoleProperties(roleOption.Name, roleOption.AssumedBy.ToArray(), roleOption.Name, roleOption.AwsActions.ToArray(), new string[] { "*" })); } else { throw new ArgumentException($"The role {roleOption.Id} must have either a list of AwsPolicies, a list of CustomPolicies or a list of AwsActions"); } return(role); }
/// <summary> /// Creates a new instance of a RoleModel class, initializes with specified arguments. /// </summary> /// <param name="role"></param> public RoleModel(RoleOptions role) { this.Name = role.Name; this.Description = role.Description; this.Composite = role.Composite; this.ClientRole = role.ClientRole; }
/// <summary> /// Checks the access token, using a request and responce. /// </summary> /// <returns> /// True if the access token is valid. /// If false, the error status code is returned by pointer on the responce. /// </returns> /// <param name="req">An HTTP request.</param> /// <param name="res">An corresponding HTTP responce.</param> /// <param name="repo">Provides the access collection.</param> /// <param name="date">Provides the datetime.</param> /// <param name="minimumRole">The minimum role needed to access a module.</param> private static async Task <bool> Check( HttpRequest req, HttpResponse res, IRepository <AccessTokenSchema> repo, IDateExtra date, RoleOptions minimumRole = RoleOptions.Normal) { string token = req.Cookies["ExperienceCapture-Access-Token"]; if (token == null) { res.StatusCode = Status400BadRequest; return(false); } var accessTokenDoc = await repo.FindOne( Builders <AccessTokenSchema> .Filter .Where(a => a.Hash == PasswordHasher.Hash(token))); if (accessTokenDoc == null || accessTokenDoc.CreatedAt.IsAfter(date, accessTokenDoc.ExpirationSeconds) || (int)accessTokenDoc.Role < (int)minimumRole) { res.StatusCode = Status401Unauthorized; return(false); } return(true); }
public User(string userId, string fullName, string phoneCountryCode, long phoneNumber, DateTime createdAt, RoleOptions role, bool isEmailVerified, bool status, string email, string registrationNumber, string password) : base(userId, fullName, registrationNumber, phoneCountryCode, phoneNumber, createdAt, role, isEmailVerified, status) { Email = email; Password = password; }
public override async Task <PaginateRolesResponse> PaginateRoles(PaginateRolesRequest request, ServerCallContext context) { var options = new RoleOptions { PageIndex = request.PageIndex, PageSize = request.PageSize, }; var roles = await _authorizationApp.GetRolesAsync(options); var items = roles.Items.Select(x => new PaginateRolesResponse.Types.Role { Id = x.Id, Name = x.Name, IsEnabled = x.IsEnabled, }); var result = new PaginateRolesResponse { PageIndex = roles.PageIndex, PageSize = roles.PageSize, ItemCount = roles.ItemCount, }; result.Items.AddRange(items); return(result); }
public BatchQueries( ICurrentUserService currentUserService, IHttpContextAccessor httpContextAccessor, IOptionsSnapshot <RoleOptions> roleOptions) : base(currentUserService, httpContextAccessor) { _roleOptions = roleOptions.Value; }
public User(string userId, string fullName, string phoneCountryCode, long phoneNumber, DateTime createdAt, RoleOptions role, bool status, string email, string password, string token, int expiresIn) : this(userId, fullName, phoneCountryCode, phoneNumber, createdAt, role, status, email, password) { Token = token; ExpiresIn = expiresIn; }
public TokenModel(string name, string email, RoleOptions role, string token, int expiresIn) { Name = name; Email = email; Role = role; Token = token; ExpiresIn = expiresIn; }
public Person(string userId, string fullName, string registrationNumber, string phoneCountryCode, long phoneNumber, DateTime createdAt, RoleOptions role, bool isEmailVerified, bool status, IEnumerable <Interaction> productInteractions) : this(userId, fullName, registrationNumber, phoneCountryCode, phoneNumber, createdAt, role, isEmailVerified, status) { ProductInteractions = productInteractions; }
public ObservationQueries( IOptionsSnapshot <RoleOptions> roleOptions, ICurrentUserService currentUserService, IHttpContextAccessor httpContextAccessor) : base(currentUserService, httpContextAccessor) { _roleOptions = roleOptions.Value; }
public UserLDAPModel Login(string username, string password) { try { var bindDn = string.Format(_config.BindDn, username); _connection.Connect(_config.Url, LdapConnection.DefaultSslPort); _connection.Bind(bindDn, password); if (_connection.Bound) { var result = _connection.Search ( bindDn, LdapConnection.ScopeSub, null, new[] { _config.MapMemberOfAttribute, _config.MapDisplayNameAttribute, _config.MapFullNameAttribute, _config.MapUIDAttribute }, false ); var user = result.Next(); if (user != null) { RoleOptions role = RoleOptions.Student; foreach (var group in _mapGroup.Keys) { if (user.GetAttribute(_config.MapMemberOfAttribute).StringValue.ToLower().Contains(group)) { role = _mapGroup[group]; break; } } return(new UserLDAPModel ( user.GetAttribute(_config.MapFullNameAttribute).StringValue, user.GetAttribute(_config.MapDisplayNameAttribute).StringValue, user.GetAttribute(_config.MapUIDAttribute).StringValue, password, role == RoleOptions.Admin ? RoleOptions.Librarian : role )); } } } catch (LdapException ex) { throw ex; } catch (Exception ex) { throw ex; } finally { _connection?.Disconnect(); } return(null); }
public UserLDAPModel(string fullName, string displayName, string username, string password, RoleOptions role) { FullName = fullName; DisplayName = displayName; Username = username; Password = password; Role = role; }
public ChangeUserRolesCommandHandler( ISheaftMediatr mediatr, IAppDbContext context, ILogger <ChangeUserRolesCommandHandler> logger, IOptionsSnapshot <RoleOptions> roleOptions) : base(mediatr, context, logger) { _roleOptions = roleOptions.Value; }
public DeleteAgreementCommandsHandler( ISheaftMediatr mediatr, IAppDbContext context, IOptionsSnapshot <RoleOptions> roleOptions, ILogger <DeleteAgreementCommandsHandler> logger) : base(mediatr, context, logger) { _roleOptions = roleOptions.Value; }
public RegisterStoreCommandHandler( IAppDbContext context, ISheaftMediatr mediatr, ILogger <RegisterStoreCommandHandler> logger, IOptionsSnapshot <RoleOptions> roleOptions) : base(mediatr, context, logger) { _roleOptions = roleOptions.Value; }
/// <summary> /// A wrapper for the check static method, it keep the interface clean. /// </summary> /// <returns> /// True if the access token is valid. /// If false, the error status code is returned by pointer on the responce. /// </returns> /// <param name="req">An HTTP request.</param> /// <param name="res">An corresponding HTTP responce.</param> /// <param name="repo">Provides the access collection.</param> /// <param name="date">Provides the datetime.</param> /// <param name="minimumRole">The minimum role needed to access a module.</param> public static async Task <bool> CheckAccessDirectly( HttpRequest req, HttpResponse res, IRepository <AccessTokenSchema> repo, IDateExtra date, RoleOptions minimumRole = RoleOptions.Normal) { return(await Check(req, res, repo, date, minimumRole)); }
public ChangeAgreementDeliveryCommandHandler( ISheaftMediatr mediatr, IAppDbContext context, IOptionsSnapshot <RoleOptions> roleOptions, ILogger <ChangeAgreementDeliveryCommandHandler> logger) : base(mediatr, context, logger) { _roleOptions = roleOptions.Value; }
public ProductQueries( ICurrentUserService currentUserService, IOptionsSnapshot <RoleOptions> roleOptions, IOptionsSnapshot <SearchOptions> searchOptions, IHttpContextAccessor httpContextAccessor) : base(currentUserService, httpContextAccessor) { _roleOptions = roleOptions.Value; _searchOptions = searchOptions.Value; }
/// <summary> /// Checks the access token. /// </summary> /// <returns> /// A function that returns true if the access token is valid. /// </returns> /// <param name="repo">Provides the access collection.</param> /// <param name="date">Provides the datetime.</param> /// <param name="minimumRole">The minimum role needed to access a module.</param> public static Func <HttpContext, Task <bool> > CheckAccess( IRepository <AccessTokenSchema> repo, IDateExtra date, RoleOptions minimumRole = RoleOptions.Normal) { return((ctx) => { return Check(ctx.Request, ctx.Response, repo, date, minimumRole); }); }
public DeliveryModeQueries( ICurrentUserService currentUserService, IHttpContextAccessor httpContextAccessor, ITableService tableService, IOptionsSnapshot <RoleOptions> roleOptions) : base(currentUserService, httpContextAccessor) { _tableService = tableService; _roleOptions = roleOptions.Value; }
private ProfileModel(int id, string account, string password, string fullname, RoleOptions roleValue, string imageLink) : base(id, StatusOptions.Actived) { Account = account; Password = password; ConfirmPassword = password; FullName = fullname; RoleValue = roleValue; ImageLink = imageLink; }
public UpdateProducerCommandHandler( IAppDbContext context, ISheaftMediatr mediatr, IPictureService imageService, ILogger <UpdateProducerCommandHandler> logger, IOptionsSnapshot <RoleOptions> roleOptions) : base(mediatr, context, logger) { _imageService = imageService; _roleOptions = roleOptions.Value; }
public SendRecallCommandHandler( ISheaftMediatr mediatr, IAppDbContext context, ICurrentUserService currentUserService, IOptionsSnapshot <RoleOptions> roleOptions, ILogger <SendRecallCommandHandler> logger) : base(mediatr, context, logger) { _currentUserService = currentUserService; _roleOptions = roleOptions.Value; }
public Person(string userId, string fullName, string phoneCountryCode, long phoneNumber, DateTime createdAt, RoleOptions role, bool status) { UserId = userId; FullName = fullName; PhoneCountryCode = string.IsNullOrEmpty(phoneCountryCode) ? "+237" : phoneCountryCode; PhoneNumber = phoneNumber; CreatedAt = createdAt; Role = role; Status = status; }
public ChatController(IChatRepository repository, ConnectionManager connectionManager, IHubContext <ChatHub> chatHub, IOptions <RoleOptions> roleOptions) { _repository = repository; _connectionManager = connectionManager; _chatHub = chatHub; _roleOptions = roleOptions.Value; // TODO: Fix this //adminRole = _roleOptions.AdminRole; //chatEmployeeRole = _roleOptions.ChatEmployeeRole; }
public Handler(IMisDbContext context, IMediator mediator, IPasswordService passwordService, UserManager <User> userManager, IOptionsMonitor <RoleOptions> roleOptions) { _context = context; _mediator = mediator; _passwordService = passwordService; _userManager = userManager; _roleOptions = roleOptions.CurrentValue; }
public Person(string userId, string fullName, string registrationNumber, string phoneCountryCode, long phoneNumber, DateTime createdAt, RoleOptions role, bool isEmailVerified, bool status) : this() { UserId = userId; FullName = fullName; RegistrationNumber = registrationNumber; PhoneCountryCode = string.IsNullOrEmpty(phoneCountryCode) ? "+237" : phoneCountryCode; PhoneNumber = phoneNumber; CreatedAt = createdAt; Role = role; IsEmailVerified = isEmailVerified; Status = status; }
public UserListModel(string id, string email, string phoneCountryCode, long phoneNumber, string registrationNumber, string fullname, DateTime createdDate, RoleOptions role, bool status) { Id = id; Email = email; PhoneCountryCode = phoneCountryCode; Phonenumber = phoneNumber; RegistrationNumber = registrationNumber; Fullname = fullname; CreatedDate = createdDate; Role = role; Status = status ? "Enabled" : "Disabled"; }