Code Explainers

Code explainers tagged #authorization

ruby
class ArticlesController < ApplicationController
  before_action :set_article, only: %i[show edit update destroy publish]
 
  def edit

Policy-based authorization in a Rails controller

authorization policy-object before-action
Intermediate 9 steps
typescript
import { inject } from '@angular/core';
import {
  CanActivateFn,
  Router,

Functional route guards in Angular

route-guards dependency-injection observables
Intermediate 5 steps
typescript
import {
  CanActivate,
  ExecutionContext,
  Injectable,

Role-based route guards in NestJS

authorization decorators metadata-reflection
Intermediate 8 steps
javascript
'use server'
 
import { revalidatePath } from 'next/cache'
import { redirect } from 'next/navigation'

How a Next.js Server Action updates a post

server-actions authorization validation
Intermediate 7 steps
php
<?php
 
namespace App\Policies;
 

How authorization policies gate updates in Laravel

authorization policies access control
Intermediate 7 steps
php
<?php
 
namespace App\Http\Requests;
 

How a Laravel FormRequest validates input

validation form-request input-sanitization
Intermediate 6 steps
ruby
class ArticlesController < ApplicationController
  before_action :authenticate_user!
  before_action :set_article, only: %i[show edit update destroy]
  before_action :authorize_owner!, only: %i[edit update destroy]

How before_action filters guard a Rails controller

filters authorization callbacks
Intermediate 9 steps