Esempio n. 1
0
        public async Task <ActionResult <UserViewModel> > Get([FromRoute] Guid id)
        {
            var user = await database.GetById <UserModel>(id);

            if (user == null)
            {
                return(NotFound());
            }

            return(Ok(new UserViewModel(user)));
        }
Esempio n. 2
0
        public async Task <ActionResult <LinkViewModel> > Get([FromRoute] Guid id)
        {
            var link = await database.GetById <LinkModel>(id);

            if (link == null)
            {
                return(NotFound());
            }

            if (!Can(Permissions.VIEW_LINKS, link))
            {
                return(NotFound());
            }

            return(Ok(new LinkViewModel(link, AuthorizedUser)));
        }
Esempio n. 3
0
        public override async Task OnActionExecutionAsync(ActionExecutingContext ctx, ActionExecutionDelegate next)
        {
            var controller = ctx.Controller as IAuthorizedController;

            if (controller == null)
            {
                SetUnauthorized(ctx);
                return;
            }

            controller.AuthClaims = await TryGetAuthClaims(ctx);

            if (controller.AuthClaims == null)
            {
                SetUnauthorized(ctx);
                return;
            }

            controller.AuthorizedUser = await database.GetById <UserModel>(controller.AuthClaims.Guid);

            if (controller.AuthorizedUser == null)
            {
                SetUnauthorized(ctx);
                return;
            }

            await base.OnActionExecutionAsync(ctx, next);
        }
Esempio n. 4
0
 public T GetById(object objId)
 {
     return(_databaseAccess.GetById(objId));
 }