parent
eefabdf53d
commit
d2ec4db516
@ -0,0 +1,56 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/** |
||||||
|
* Authserver, an OAuth2-based single-signon authentication provider written in PHP. |
||||||
|
* |
||||||
|
* Copyright (C) $today.date Lars Vierbergen |
||||||
|
* |
||||||
|
* his program is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU Affero General Public License as |
||||||
|
* published by the Free Software Foundation, either version 3 of the |
||||||
|
* License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* This program is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU Affero General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Affero General Public License |
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
*/ |
||||||
|
namespace vierbergenlars\AuthserverExternalAccountBundle\Controller; |
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
||||||
|
use Symfony\Component\Form\Extension\Core\Type\FormType; |
||||||
|
use Symfony\Component\HttpFoundation\Request; |
||||||
|
use vierbergenlars\AuthserverExternalAccountBundle\Entity\ExternalUser; |
||||||
|
|
||||||
|
class ConnectController extends Controller |
||||||
|
{ |
||||||
|
|
||||||
|
public function disconnectServiceAction(Request $request, ExternalUser $externalUser) |
||||||
|
{ |
||||||
|
$externalAccountProviderManager = $this->get('vierbergenlars.authserver_external_account.account_provider_manager'); |
||||||
|
/* @var $externalAccountProviderManager \vierbergenlars\AuthserverExternalAccountBundle\ExternalAccount\ExternalAccountProviderManager */ |
||||||
|
|
||||||
|
$externalAccountProvider = $externalAccountProviderManager->getProviderForExternalUser($externalUser); |
||||||
|
|
||||||
|
if (!$externalAccountProvider->hasDisconnect()) |
||||||
|
throw $this->createNotFoundException('This account can not be disconnected.'); |
||||||
|
|
||||||
|
$form = $this->createForm(FormType::class); |
||||||
|
$form->handleRequest($request); |
||||||
|
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) { |
||||||
|
$externalAccountProvider->disconnect($externalUser); |
||||||
|
|
||||||
|
return $this->redirectToRoute('user_profile'); |
||||||
|
} |
||||||
|
|
||||||
|
return $this->render('AuthserverExternalAccountBundle:Connect:disconnect_service.html.twig', [ |
||||||
|
'externalAccountProvider' => $externalAccountProvider, |
||||||
|
'externalUser' => $externalUser, |
||||||
|
'form' => $form->createView() |
||||||
|
]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
vierbergenlars_external_account_disconnect: |
||||||
|
path: /usr/external/disconnect/{externalUser} |
||||||
|
defaults: |
||||||
|
_controller: AuthserverExternalAccountBundle:Connect:disconnectService |
@ -0,0 +1,27 @@ |
|||||||
|
{% extends '::base.html.twig' %} |
||||||
|
{% block title %}{{ parent() }} - Disconnect Account{% endblock %} |
||||||
|
{% block body %} |
||||||
|
<div class="container"> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-xs-12 col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4"> |
||||||
|
<div class="panel panel-primary"> |
||||||
|
<div class="panel-heading"> |
||||||
|
<h3 class="panel-title">Disconnecting</h3> |
||||||
|
</div> |
||||||
|
<div class="panel-body"> |
||||||
|
<p>Are you sure you want to disconnect your {{ externalAccountProvider.serviceName }} account "{{ externalUser.providerFriendlyName }}"?</p> |
||||||
|
<p> |
||||||
|
{{ form_start(form) }} |
||||||
|
{{ form_widget(form) }} |
||||||
|
<div> |
||||||
|
<button type="submit" class="btn btn-primary">Disconnect account</button> |
||||||
|
<a href="{{ path('user_profile') }}" class="btn btn-link">Cancel</a> |
||||||
|
</div> |
||||||
|
{{ form_end(form) }} |
||||||
|
</p> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{% endblock %} |
Reference in new issue