Activities of "tomcic"

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v4.2.2.
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

How to set permissions to gain access for the user who has been assigned the permission WorkAppPermissions.WorkLogs.Default or WorkAppPermissions.WorkLogsPowerAdmin.Default ?

Thanks :)

namespace WorkApp.WorkLogs {

[Authorize(WorkAppPermissions.WorkLogs.Default)] OR [Authorize(WorkAppPermissions.WorkLogsPowerAdmin.Default)]                       //<=================== pseudocode P1 OR P2

> public class WorkLogAppService : ApplicationService, IWorkLogAppService

{
    private readonly IWorkLogRepository _workLogRepository;
    private readonly IRepository<AppUser, Guid> _appUserRepository;

    public WorkLogAppService(IWorkLogRepository workLogRepository, IRepository<AppUser, Guid> appUserRepository)
    {
        _workLogRepository = workLogRepository; _appUserRepository = appUserRepository;
    }

    public virtual async Task<PagedResultDto<WorkLogWithNavigationPropertiesDto>> GetListAsync(GetWorkLogsInput input)
    {
        var totalCount = await _workLogRepository.GetCountAsync(input.FilterText, input.Title, input.StartDateMin, input.StartDateMax, input.EndDateMin, input.EndDateMax, input.Description, input.AppUserId);
        var items = await _workLogRepository.GetListWithNavigationPropertiesAsync(input.FilterText, input.Title, input.StartDateMin, input.StartDateMax, input.EndDateMin, input.EndDateMax, input.Description, input.AppUserId, input.Sorting, input.MaxResultCount, input.SkipCount);

        return new PagedResultDto<WorkLogWithNavigationPropertiesDto>
        {
            TotalCount = totalCount,
            Items = ObjectMapper.Map<List<WorkLogWithNavigationProperties>, List<WorkLogWithNavigationPropertiesDto>>(items)
        };
    }

    public virtual async Task<WorkLogWithNavigationPropertiesDto> GetWithNavigationPropertiesAsync(Guid id)
    {
        return ObjectMapper.Map<WorkLogWithNavigationProperties, WorkLogWithNavigationPropertiesDto>
            (await _workLogRepository.GetWithNavigationPropertiesAsync(id));
    }

    public virtual async Task<WorkLogDto> GetAsync(Guid id)
    {
        return ObjectMapper.Map<WorkLog, WorkLogDto>(await _workLogRepository.GetAsync(id));
    }

    public virtual async Task<PagedResultDto<LookupDto<Guid?>>> GetAppUserLookupAsync(LookupRequestDto input)
    {
        var query = _appUserRepository.AsQueryable()
            .WhereIf(!string.IsNullOrWhiteSpace(input.Filter),
                x => x.UserName != null &&
                     x.UserName.Contains(input.Filter));

        var lookupData = await query.PageBy(input.SkipCount, input.MaxResultCount).ToDynamicListAsync<AppUser>();
        var totalCount = query.Count();
        return new PagedResultDto<LookupDto<Guid?>>
        {
            TotalCount = totalCount,
            Items = ObjectMapper.Map<List<AppUser>, List<LookupDto<Guid?>>>(lookupData)
        };
    }

    [Authorize(WorkAppPermissions.WorkLogs.Delete)]
    public virtual async Task DeleteAsync(Guid id)
    {
        await _workLogRepository.DeleteAsync(id);
    }

    [Authorize(WorkAppPermissions.WorkLogs.Create)]
    public virtual async Task<WorkLogDto> CreateAsync(WorkLogCreateDto input)
    {
        var workLog = ObjectMapper.Map<WorkLogCreateDto, WorkLog>(input);

        workLog = await _workLogRepository.InsertAsync(workLog, autoSave: true);
        return ObjectMapper.Map<WorkLog, WorkLogDto>(workLog);
    }

    [Authorize(WorkAppPermissions.WorkLogs.Edit)]
    public virtual async Task<WorkLogDto> UpdateAsync(Guid id, WorkLogUpdateDto input)
    {
        var workLog = await _workLogRepository.GetAsync(id);
        ObjectMapper.Map(input, workLog);
        workLog = await _workLogRepository.UpdateAsync(workLog);
        return ObjectMapper.Map<WorkLog, WorkLogDto>(workLog);
    }
}

}

Question

v4.2.2 MVC EF Core Tiered: no

I would like to limit the visibility of some users' data to their data only (via appuserID or tenant) - how can I do this?

v4.0.2, MVC

After logging in, I would like the application to check whether the user has completed the data, if not, I would like to hide some functions for him and force a redirection to the page with the form.

Showing 1 to 3 of 3 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35