mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-24 09:50:39 +00:00
controller refactoring part 24
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace Domain\Sharing\Controllers;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Domain\Sharing\Resources\ShareResource;
|
||||
use Domain\Sharing\Requests\AuthenticateShareRequest;
|
||||
|
||||
class VisitorUnlockLockedShareController extends Controller
|
||||
{
|
||||
/**
|
||||
* Check Password for protected item
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __invoke(
|
||||
AuthenticateShareRequest $request,
|
||||
Share $shared,
|
||||
): Response {
|
||||
// Check password
|
||||
if (Hash::check($request->input('password'), $shared->password)) {
|
||||
$cookie = json_encode([
|
||||
'token' => $shared->token,
|
||||
'authenticated' => true,
|
||||
]);
|
||||
|
||||
// Return authorize token with shared options
|
||||
return response(new ShareResource($shared), 200)
|
||||
->cookie('share_session', $cookie, 43200);
|
||||
}
|
||||
|
||||
return response(__t('incorrect_password'), 401);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user