feat: harden identity and recovery operations
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Domain\Identity\Exceptions\MicrosoftAuthenticationException;
|
||||
use App\Domain\Identity\Services\MicrosoftIdentityService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Integrations\Microsoft\MicrosoftOidcClient;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
final class MicrosoftIdentityController extends Controller
|
||||
{
|
||||
public function redirect(Request $request, MicrosoftOidcClient $client): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$authorization = $client->authorizationRequest();
|
||||
} catch (MicrosoftAuthenticationException $exception) {
|
||||
return back()->with('error', $exception->getMessage());
|
||||
}
|
||||
$request->session()->put('microsoft_oidc', [
|
||||
...$authorization['flow'],
|
||||
'intent' => 'link',
|
||||
'user_id' => $request->user()->id,
|
||||
]);
|
||||
|
||||
return redirect()->away($authorization['url']);
|
||||
}
|
||||
|
||||
public function destroy(Request $request, MicrosoftIdentityService $identities): RedirectResponse
|
||||
{
|
||||
$identities->unlink($request->user(), $request);
|
||||
|
||||
return back()->with('success', 'Associação à identidade Microsoft removida.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user