Authentication and Authorization in DDD
José Luis Martínez de la
453

What do you think about your Application Service classes to implement an interface „AuthorizableInterface„ thad demand two methods

  • fromUser(User $user)
  • isAllowed($request);
  • execute($request)

Your class AddPostService would be uses something like this

function addNewPost(){`

$service = new AddPostService();

$service->fromUser($user);

if($user->allow()){
$service->execute($request);

}
}

Or shortly

function addNewPost(){`

$this->doIt(new AddPostService(), $request, $user);

}

private function doIt($service, $request, $user): void

{

$service->fromUser($user);

if ($user->allow()) {

$service->execute($request);

}

}

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.