mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-01 23:31:50 +02:00
Added almost full registrar impersonation
This commit is contained in:
parent
b7c375ede2
commit
34d966aeeb
4 changed files with 45 additions and 1 deletions
|
@ -7,6 +7,7 @@ use Psr\Http\Message\ServerRequestInterface as Request;
|
|||
use Psr\Container\ContainerInterface;
|
||||
use League\ISO3166\ISO3166;
|
||||
use Respect\Validation\Validator as v;
|
||||
use App\Auth\Auth;
|
||||
|
||||
class RegistrarsController extends Controller
|
||||
{
|
||||
|
@ -1223,4 +1224,27 @@ class RegistrarsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function impersonateRegistrar(Request $request, Response $response, $args)
|
||||
{
|
||||
if ($_SESSION["auth_roles"] != 0) {
|
||||
return $response->withHeader('Location', '/dashboard')->withStatus(302);
|
||||
}
|
||||
|
||||
$db = $this->container->get('db');
|
||||
|
||||
if ($args) {
|
||||
$args = trim($args);
|
||||
|
||||
$registrar_id = $db->selectValue('SELECT id FROM registrar WHERE clid = ?',
|
||||
[ $args ]);
|
||||
$user_id = $db->selectValue('SELECT user_id FROM registrar_users WHERE registrar_id = ?',
|
||||
[ $registrar_id ]);
|
||||
|
||||
Auth::impersonateUser($user_id);
|
||||
} else {
|
||||
// Redirect to the registrars view
|
||||
return $response->withHeader('Location', '/registrars')->withStatus(302);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue