login pages with warning
This commit is contained in:
parent
1ac424365c
commit
e8b4e5fe10
@ -11,7 +11,7 @@
|
||||
|
||||
ou bien,
|
||||
|
||||
<a class="btn btn-info" href="/login">se connecter.</a>
|
||||
<a class="btn btn-info" href="{{ path('fos_user_security_login') }}">se connecter.</a>
|
||||
<a class="btn btn-info" href="{{ path('fos_user_resetting_request') }}">
|
||||
Mot de passe oublié?
|
||||
</a>
|
||||
|
@ -1,5 +1,6 @@
|
||||
{% extends "@FOSUser/layout.html.twig" %}
|
||||
|
||||
{% block bigMain %}
|
||||
{% block fos_user_content %}
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
@ -7,7 +8,29 @@
|
||||
<i class="fa fa-key"></i>
|
||||
Se connecter
|
||||
</h1>
|
||||
{{ include('@FOSUser/Security/login_content.html.twig') }}
|
||||
{% if error %}
|
||||
<div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
|
||||
{% endif %}
|
||||
|
||||
<form action="{{ path("fos_user_security_check") }}" method="post">
|
||||
{% if csrf_token %}
|
||||
<input type="hidden" name="_csrf_token" value="{{ csrf_token }}"/>
|
||||
{% endif %}
|
||||
|
||||
<label for="username">{{ 'security.login.username'|trans }}</label>
|
||||
<input type="text" id="username" name="_username" value="{{ last_username }}" required="required"
|
||||
autocomplete="username"/>
|
||||
|
||||
<label for="password">{{ 'security.login.password'|trans }}</label>
|
||||
<input type="password" id="password" name="_password" required="required"
|
||||
autocomplete="current-password"/>
|
||||
|
||||
<input type="checkbox" id="remember_me" name="_remember_me" value="on"/>
|
||||
<label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>
|
||||
|
||||
<input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans }}"/>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<p>
|
||||
@ -27,3 +50,5 @@
|
||||
|
||||
|
||||
{% endblock fos_user_content %}
|
||||
|
||||
{% endblock %}
|
||||
|
@ -1,17 +1,63 @@
|
||||
{% extends '::default/index.html.twig' %}
|
||||
|
||||
{% trans_default_domain 'FOSUserBundle' %}
|
||||
{% block title %}Caisse{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
{% block bigMain %}
|
||||
{% include 'default/header.html.twig' %}
|
||||
<section class="bg-girl padded">
|
||||
<div class="container">
|
||||
<div class="row justify-content-md-center align-items-center">
|
||||
<div class="col-md-auto">
|
||||
<div class="well form-group">
|
||||
<fieldset class="bg-shader pull-left form-group padded">
|
||||
|
||||
{#<div class="row">#}
|
||||
{#<div class="col-xs-6">#}
|
||||
{#<h1>#}
|
||||
{#<i class="fa fa-key"></i>#}
|
||||
{#Se connecter#}
|
||||
{#</h1>#}
|
||||
{#{% if error is defined %}#}
|
||||
{#<div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>#}
|
||||
{#{% endif %}#}
|
||||
|
||||
{#<form action="{{ path("fos_user_security_check") }}" method="post">#}
|
||||
{#{% if csrf_token is defined %}#}
|
||||
{#<input type="hidden" name="_csrf_token" value="{{ csrf_token }}"/>#}
|
||||
{#{% endif %}#}
|
||||
|
||||
{#<label for="username">{{ 'security.login.username'|trans }}</label>#}
|
||||
{#<input type="text" id="username" name="_username" value=""#}
|
||||
{#required="required"#}
|
||||
{#autocomplete="username"/>#}
|
||||
|
||||
{#<label for="password">{{ 'security.login.password'|trans }}</label>#}
|
||||
{#<input type="password" id="password" name="_password" required="required"#}
|
||||
{#autocomplete="current-password"/>#}
|
||||
|
||||
{#<input type="checkbox" id="remember_me" name="_remember_me" value="on"/>#}
|
||||
{#<label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>#}
|
||||
|
||||
{#<input type="submit" id="_submit" name="_submit"#}
|
||||
{#value="{{ 'security.login.submit'|trans }}"/>#}
|
||||
{#</form>#}
|
||||
|
||||
{#</div>#}
|
||||
{#<div class="col-xs-6">#}
|
||||
{#<p>#}
|
||||
|
||||
{#<a class="btn btn-info" href="{{ path('fos_user_resetting_request') }}">#}
|
||||
{#Mot de passe oublié?#}
|
||||
{#</a>#}
|
||||
{#</p>#}
|
||||
{#</div>#}
|
||||
{#</div>#}
|
||||
|
||||
{% block fos_user_content %}{% endblock %}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% include 'default/footer.html.twig' %}
|
||||
{% endblock %}
|
||||
|
@ -1,496 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the HWIOAuthBundle package.
|
||||
*
|
||||
* (c) Hardware.Info <opensource@hardware.info>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace HWI\Bundle\OAuthBundle\Controller;
|
||||
|
||||
use HWI\Bundle\OAuthBundle\Event\FilterUserResponseEvent;
|
||||
use HWI\Bundle\OAuthBundle\Event\FormEvent;
|
||||
use HWI\Bundle\OAuthBundle\Event\GetResponseUserEvent;
|
||||
use HWI\Bundle\OAuthBundle\HWIOAuthEvents;
|
||||
use HWI\Bundle\OAuthBundle\OAuth\ResourceOwnerInterface;
|
||||
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
|
||||
use HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken;
|
||||
use HWI\Bundle\OAuthBundle\Security\Core\Exception\AccountNotLinkedException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Security\Core\Exception\AccountStatusException;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
|
||||
use Symfony\Component\Security\Http\SecurityEvents;
|
||||
|
||||
/**
|
||||
* @author Alexander <iam.asm89@gmail.com>
|
||||
*/
|
||||
class ConnectController extends Controller {
|
||||
private $tokenManager;
|
||||
|
||||
public function __construct( CsrfTokenManagerInterface $tokenManager = null ) {
|
||||
$this->tokenManager = $tokenManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action that handles the login 'form'. If connecting is enabled the
|
||||
* user will be redirected to the appropriate login urls or registration forms.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws \LogicException
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function connectAction( Request $request ) {
|
||||
var_dump( "overrided" );
|
||||
$connect = $this->container->getParameter( 'hwi_oauth.connect' );
|
||||
$hasUser = $this->getUser() ? $this->isGranted( $this->container->getParameter( 'hwi_oauth.grant_rule' ) ) : false;
|
||||
|
||||
$error = $this->getErrorForRequest( $request );
|
||||
|
||||
// if connecting is enabled and there is no user, redirect to the registration form
|
||||
if ( $connect && ! $hasUser && $error instanceof AccountNotLinkedException ) {
|
||||
$key = time();
|
||||
$session = $request->getSession();
|
||||
$session->set( '_hwi_oauth.registration_error.' . $key, $error );
|
||||
|
||||
return $this->redirectToRoute( 'hwi_oauth_connect_registration', [ 'key' => $key ] );
|
||||
}
|
||||
|
||||
if ( $error ) {
|
||||
if ( $error instanceof AuthenticationException ) {
|
||||
$error = $error->getMessageKey();
|
||||
} else {
|
||||
$error = $error->getMessage();
|
||||
}
|
||||
}
|
||||
$csrfToken = $this->tokenManager
|
||||
? $this->tokenManager->getToken( 'authenticate' )->getValue()
|
||||
: null;
|
||||
|
||||
return $this->render( '@HWIOAuth/Connect/login.html.twig',
|
||||
[
|
||||
'error' => $error,
|
||||
'csrf_token' => $csrfToken,
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a registration form if there is no user logged in and connecting
|
||||
* is enabled.
|
||||
*
|
||||
* @param Request $request a request
|
||||
* @param string $key key used for retrieving the right information for the registration form
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @throws NotFoundHttpException if `connect` functionality was not enabled
|
||||
* @throws AccessDeniedException if any user is authenticated
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function registrationAction( Request $request, $key ) {
|
||||
$connect = $this->container->getParameter( 'hwi_oauth.connect' );
|
||||
if ( ! $connect ) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$hasUser = $this->isGranted( $this->container->getParameter( 'hwi_oauth.grant_rule' ) );
|
||||
if ( $hasUser ) {
|
||||
throw new AccessDeniedException( 'Cannot connect already registered account.' );
|
||||
}
|
||||
|
||||
$session = $request->getSession();
|
||||
$error = $session->get( '_hwi_oauth.registration_error.' . $key );
|
||||
$session->remove( '_hwi_oauth.registration_error.' . $key );
|
||||
|
||||
if ( ! $error instanceof AccountNotLinkedException ) {
|
||||
throw new \RuntimeException( 'Cannot register an account.',
|
||||
0,
|
||||
$error instanceof \Exception ? $error : null );
|
||||
}
|
||||
|
||||
$userInformation = $this
|
||||
->getResourceOwnerByName( $error->getResourceOwnerName() )
|
||||
->getUserInformation( $error->getRawToken() );
|
||||
|
||||
/* @var $form FormInterface */
|
||||
if ( $this->container->getParameter( 'hwi_oauth.fosub_enabled' ) ) {
|
||||
// enable compatibility with FOSUserBundle 1.3.x and 2.x
|
||||
if ( interface_exists( 'FOS\UserBundle\Form\Factory\FactoryInterface' ) ) {
|
||||
$form = $this->container->get( 'hwi_oauth.registration.form.factory' )->createForm();
|
||||
} else {
|
||||
$form = $this->container->get( 'hwi_oauth.registration.form' );
|
||||
}
|
||||
} else {
|
||||
$form = $this->container->get( 'hwi_oauth.registration.form' );
|
||||
}
|
||||
|
||||
$formHandler = $this->container->get( 'hwi_oauth.registration.form.handler' );
|
||||
if ( $formHandler->process( $request, $form, $userInformation ) ) {
|
||||
$event = new FormEvent( $form, $request );
|
||||
$this->get( 'event_dispatcher' )->dispatch( HWIOAuthEvents::REGISTRATION_SUCCESS, $event );
|
||||
|
||||
$this->container->get( 'hwi_oauth.account.connector' )->connect( $form->getData(), $userInformation );
|
||||
|
||||
// Authenticate the user
|
||||
$this->authenticateUser( $request,
|
||||
$form->getData(),
|
||||
$error->getResourceOwnerName(),
|
||||
$error->getAccessToken() );
|
||||
|
||||
if ( null === $response = $event->getResponse() ) {
|
||||
if ( $targetPath = $this->getTargetPath( $session ) ) {
|
||||
$response = $this->redirect( $targetPath );
|
||||
} else {
|
||||
$response = $this->render( '@HWIOAuth/Connect/registration_success.html.twig',
|
||||
[
|
||||
'userInformation' => $userInformation,
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
$event = new FilterUserResponseEvent( $form->getData(), $request, $response );
|
||||
$this->get( 'event_dispatcher' )->dispatch( HWIOAuthEvents::REGISTRATION_COMPLETED, $event );
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
// reset the error in the session
|
||||
$session->set( '_hwi_oauth.registration_error.' . $key, $error );
|
||||
|
||||
$event = new GetResponseUserEvent( $form->getData(), $request );
|
||||
$this->get( 'event_dispatcher' )->dispatch( HWIOAuthEvents::REGISTRATION_INITIALIZE, $event );
|
||||
|
||||
if ( $response = $event->getResponse() ) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->render( '@HWIOAuth/Connect/registration.html.twig',
|
||||
[
|
||||
'key' => $key,
|
||||
'form' => $form->createView(),
|
||||
'userInformation' => $userInformation,
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects a user to a given account if the user is logged in and connect is enabled.
|
||||
*
|
||||
* @param Request $request the active request
|
||||
* @param string $service name of the resource owner to connect to
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @throws NotFoundHttpException if `connect` functionality was not enabled
|
||||
* @throws AccessDeniedException if no user is authenticated
|
||||
*/
|
||||
public function connectServiceAction( Request $request, $service ) {
|
||||
$connect = $this->container->getParameter( 'hwi_oauth.connect' );
|
||||
if ( ! $connect ) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$hasUser = $this->isGranted( $this->container->getParameter( 'hwi_oauth.grant_rule' ) );
|
||||
if ( ! $hasUser ) {
|
||||
throw new AccessDeniedException( 'Cannot connect an account.' );
|
||||
}
|
||||
|
||||
// Get the data from the resource owner
|
||||
$resourceOwner = $this->getResourceOwnerByName( $service );
|
||||
|
||||
$session = $request->getSession();
|
||||
$key = $request->query->get( 'key', time() );
|
||||
|
||||
if ( $resourceOwner->handles( $request ) ) {
|
||||
$accessToken = $resourceOwner->getAccessToken(
|
||||
$request,
|
||||
$this->container->get( 'hwi_oauth.security.oauth_utils' )->getServiceAuthUrl( $request, $resourceOwner )
|
||||
);
|
||||
|
||||
// save in session
|
||||
$session->set( '_hwi_oauth.connect_confirmation.' . $key, $accessToken );
|
||||
} else {
|
||||
$accessToken = $session->get( '_hwi_oauth.connect_confirmation.' . $key );
|
||||
}
|
||||
|
||||
// Redirect to the login path if the token is empty (Eg. User cancelled auth)
|
||||
if ( null === $accessToken ) {
|
||||
if ( $this->container->getParameter( 'hwi_oauth.failed_use_referer' ) && $targetPath = $this->getTargetPath( $session,
|
||||
'failed_target_path' ) ) {
|
||||
return $this->redirect( $targetPath );
|
||||
}
|
||||
|
||||
return $this->redirectToRoute( $this->container->getParameter( 'hwi_oauth.failed_auth_path' ) );
|
||||
}
|
||||
|
||||
$userInformation = $resourceOwner->getUserInformation( $accessToken );
|
||||
|
||||
// Show confirmation page?
|
||||
if ( ! $this->container->getParameter( 'hwi_oauth.connect.confirmation' ) ) {
|
||||
return $this->getConfirmationResponse( $request, $accessToken, $service );
|
||||
}
|
||||
|
||||
// Symfony <3.0 BC
|
||||
/** @var $form FormInterface */
|
||||
$form = method_exists( 'Symfony\Component\Form\AbstractType', 'getBlockPrefix' )
|
||||
? $this->createForm( FormType::class )
|
||||
: $this->createForm( 'form' );
|
||||
// Handle the form
|
||||
$form->handleRequest( $request );
|
||||
|
||||
if ( $form->isSubmitted() && $form->isValid() ) {
|
||||
return $this->getConfirmationResponse( $request, $accessToken, $service );
|
||||
}
|
||||
|
||||
$event = new GetResponseUserEvent( $this->getUser(), $request );
|
||||
$this->get( 'event_dispatcher' )->dispatch( HWIOAuthEvents::CONNECT_INITIALIZE, $event );
|
||||
|
||||
if ( $response = $event->getResponse() ) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $this->render( '@HWIOAuth/Connect/connect_confirm.html.twig',
|
||||
[
|
||||
'key' => $key,
|
||||
'service' => $service,
|
||||
'form' => $form->createView(),
|
||||
'userInformation' => $userInformation,
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param string $service
|
||||
*
|
||||
* @throws NotFoundHttpException
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function redirectToServiceAction( Request $request, $service ) {
|
||||
try {
|
||||
$authorizationUrl = $this->container->get( 'hwi_oauth.security.oauth_utils' )->getAuthorizationUrl( $request,
|
||||
$service );
|
||||
} catch ( \RuntimeException $e ) {
|
||||
throw new NotFoundHttpException( $e->getMessage(), $e );
|
||||
}
|
||||
|
||||
// Check for a return path and store it before redirect
|
||||
if ( $request->hasSession() ) {
|
||||
// initialize the session for preventing SessionUnavailableException
|
||||
$session = $request->getSession();
|
||||
$session->start();
|
||||
|
||||
foreach ( $this->container->getParameter( 'hwi_oauth.firewall_names' ) as $providerKey ) {
|
||||
$sessionKey = '_security.' . $providerKey . '.target_path';
|
||||
$sessionKeyFailure = '_security.' . $providerKey . '.failed_target_path';
|
||||
|
||||
$param = $this->container->getParameter( 'hwi_oauth.target_path_parameter' );
|
||||
if ( ! empty( $param ) && $targetUrl = $request->get( $param ) ) {
|
||||
$session->set( $sessionKey, $targetUrl );
|
||||
}
|
||||
|
||||
if ( $this->container->getParameter( 'hwi_oauth.failed_use_referer' ) && ! $session->has( $sessionKeyFailure ) && ( $targetUrl = $request->headers->get( 'Referer' ) ) && $targetUrl !== $authorizationUrl ) {
|
||||
$session->set( $sessionKeyFailure, $targetUrl );
|
||||
}
|
||||
|
||||
if ( $this->container->getParameter( 'hwi_oauth.use_referer' ) && ! $session->has( $sessionKey ) && ( $targetUrl = $request->headers->get( 'Referer' ) ) && $targetUrl !== $authorizationUrl ) {
|
||||
$session->set( $sessionKey, $targetUrl );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->redirect( $authorizationUrl );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the security error for a given request.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return string|\Exception
|
||||
*/
|
||||
protected function getErrorForRequest( Request $request ) {
|
||||
$authenticationErrorKey = Security::AUTHENTICATION_ERROR;
|
||||
|
||||
$session = $request->getSession();
|
||||
if ( $request->attributes->has( $authenticationErrorKey ) ) {
|
||||
$error = $request->attributes->get( $authenticationErrorKey );
|
||||
} elseif ( null !== $session && $session->has( $authenticationErrorKey ) ) {
|
||||
$error = $session->get( $authenticationErrorKey );
|
||||
$session->remove( $authenticationErrorKey );
|
||||
} else {
|
||||
$error = '';
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a resource owner by name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return ResourceOwnerInterface
|
||||
*
|
||||
* @throws NotFoundHttpException if there is no resource owner with the given name
|
||||
*/
|
||||
protected function getResourceOwnerByName( $name ) {
|
||||
foreach ( $this->container->getParameter( 'hwi_oauth.firewall_names' ) as $firewall ) {
|
||||
$id = 'hwi_oauth.resource_ownermap.' . $firewall;
|
||||
if ( ! $this->container->has( $id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ownerMap = $this->container->get( $id );
|
||||
if ( $resourceOwner = $ownerMap->getResourceOwnerByName( $name ) ) {
|
||||
return $resourceOwner;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException( sprintf( "No resource owner with name '%s'.", $name ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a route.
|
||||
*
|
||||
* @deprecated since version 0.4. Will be removed in 1.0.
|
||||
*
|
||||
* @param string $route Route name
|
||||
* @param array $params Route parameters
|
||||
* @param bool $absolute absolute url or note
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generate( $route, array $params = [], $absolute = false ) {
|
||||
@trigger_error( 'The ' . __METHOD__ . ' method is deprecated since version 0.4 and will be removed in 1.0. Use Symfony\Bundle\FrameworkBundle\Controller\Controller::generateUrl instead.',
|
||||
E_USER_DEPRECATED );
|
||||
|
||||
return $this->container->get( 'router' )->generate( $route, $params, $absolute );
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate a user with Symfony Security.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param UserInterface $user
|
||||
* @param string $resourceOwnerName
|
||||
* @param string $accessToken
|
||||
* @param bool $fakeLogin
|
||||
*/
|
||||
protected function authenticateUser(
|
||||
Request $request,
|
||||
UserInterface $user,
|
||||
$resourceOwnerName,
|
||||
$accessToken,
|
||||
$fakeLogin = true
|
||||
) {
|
||||
try {
|
||||
$this->container->get( 'hwi_oauth.user_checker' )->checkPreAuth( $user );
|
||||
$this->container->get( 'hwi_oauth.user_checker' )->checkPostAuth( $user );
|
||||
} catch ( AccountStatusException $e ) {
|
||||
// Don't authenticate locked, disabled or expired users
|
||||
return;
|
||||
}
|
||||
|
||||
$token = new OAuthToken( $accessToken, $user->getRoles() );
|
||||
$token->setResourceOwnerName( $resourceOwnerName );
|
||||
$token->setUser( $user );
|
||||
$token->setAuthenticated( true );
|
||||
|
||||
$this->get( 'security.token_storage' )->setToken( $token );
|
||||
|
||||
if ( $fakeLogin ) {
|
||||
// Since we're "faking" normal login, we need to throw our INTERACTIVE_LOGIN event manually
|
||||
$this->container->get( 'event_dispatcher' )->dispatch(
|
||||
SecurityEvents::INTERACTIVE_LOGIN,
|
||||
new InteractiveLoginEvent( $request, $token )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SessionInterface $session
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private function getTargetPath( SessionInterface $session ) {
|
||||
foreach ( $this->container->getParameter( 'hwi_oauth.firewall_names' ) as $providerKey ) {
|
||||
$sessionKey = '_security.' . $providerKey . '.target_path';
|
||||
if ( $session->has( $sessionKey ) ) {
|
||||
return $session->get( $sessionKey );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request The active request
|
||||
* @param array $accessToken The access token
|
||||
* @param string $service Name of the resource owner to connect to
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @throws NotFoundHttpException if there is no resource owner with the given name
|
||||
*/
|
||||
private function getConfirmationResponse( Request $request, array $accessToken, $service ) {
|
||||
/** @var $currentToken OAuthToken */
|
||||
$currentToken = $this->container->get( 'security.token_storage' )->getToken();
|
||||
/** @var $currentUser UserInterface */
|
||||
$currentUser = $currentToken->getUser();
|
||||
|
||||
/** @var $resourceOwner ResourceOwnerInterface */
|
||||
$resourceOwner = $this->getResourceOwnerByName( $service );
|
||||
/** @var $userInformation UserResponseInterface */
|
||||
$userInformation = $resourceOwner->getUserInformation( $accessToken );
|
||||
|
||||
$event = new GetResponseUserEvent( $currentUser, $request );
|
||||
$this->get( 'event_dispatcher' )->dispatch( HWIOAuthEvents::CONNECT_CONFIRMED, $event );
|
||||
|
||||
$this->container->get( 'hwi_oauth.account.connector' )->connect( $currentUser, $userInformation );
|
||||
|
||||
if ( $currentToken instanceof OAuthToken ) {
|
||||
// Update user token with new details
|
||||
$newToken =
|
||||
is_array( $accessToken ) &&
|
||||
( isset( $accessToken[ 'access_token' ] ) || isset( $accessToken[ 'oauth_token' ] ) ) ?
|
||||
$accessToken : $currentToken->getRawToken();
|
||||
|
||||
$this->authenticateUser( $request, $currentUser, $service, $newToken, false );
|
||||
}
|
||||
|
||||
if ( null === $response = $event->getResponse() ) {
|
||||
if ( $targetPath = $this->getTargetPath( $request->getSession() ) ) {
|
||||
$response = $this->redirect( $targetPath );
|
||||
} else {
|
||||
$response = $this->render( '@HWIOAuth/Connect/connect_success.html.twig',
|
||||
[
|
||||
'userInformation' => $userInformation,
|
||||
'service' => $service,
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
$event = new FilterUserResponseEvent( $currentUser, $request, $response );
|
||||
$this->get( 'event_dispatcher' )->dispatch( HWIOAuthEvents::CONNECT_COMPLETED, $event );
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -1,24 +1,91 @@
|
||||
{% trans_default_domain 'FOSUserBundle' %}
|
||||
{% extends '@HWIOAuth/layout.html.twig' %}
|
||||
{% block bigMain %}
|
||||
{% include 'default/header.html.twig' %}
|
||||
<section class="bg-girl padded">
|
||||
<div class="container">
|
||||
<div class="row justify-content-md-center align-items-center">
|
||||
<div class="col-md-auto">
|
||||
<fieldset class="bg-shader pull-left form-group padded">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<h1>
|
||||
<i class="fa fa-key"></i>
|
||||
Se connecter
|
||||
</h1>
|
||||
<div class="alert alert-info">
|
||||
En raison de maintenance technique, seul le login via twitter fonctionne
|
||||
actuellement.
|
||||
</div>
|
||||
{#{% if error %}#}
|
||||
|
||||
{#<div class="alert alert-danger">{{ error|trans }}</div>#}
|
||||
{#{% endif %}#}
|
||||
|
||||
{#<form action="{{ path("fos_user_security_check") }}" method="post">#}
|
||||
{#{% if csrf_token is defined %}#}
|
||||
{#csrf_token : {{ csrf_token }}#}
|
||||
{#<input type="hidden" name="_csrf_token" value="{{ csrf_token }}"/>#}
|
||||
{#{% else %}#}
|
||||
{#PAS DE TOKEN#}
|
||||
{#{% endif %}#}
|
||||
|
||||
{#<label for="username">{{ 'security.login.username'|trans }}</label>#}
|
||||
{#<input type="text" id="username" name="_username"#}
|
||||
{#value="" required="required"#}
|
||||
{#autocomplete="username"/>#}
|
||||
|
||||
{#<label for="password">{{ 'security.login.password'|trans }}</label>#}
|
||||
{#<input type="password" id="password" name="_password"#}
|
||||
{#required="required"#}
|
||||
{#autocomplete="current-password"/>#}
|
||||
|
||||
{#<input type="checkbox" id="remember_me" name="_remember_me" value="on"/>#}
|
||||
{#<label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>#}
|
||||
|
||||
{#<input type="submit" id="_submit" name="_submit"#}
|
||||
{#value="{{ 'security.login.submit'|trans }}"/>#}
|
||||
{#</form>#}
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
{#<p>#}
|
||||
|
||||
{#<a class="btn btn-info" href="{{ path('fos_user_resetting_request') }}">#}
|
||||
{#Mot de passe oublié?#}
|
||||
{#</a>#}
|
||||
{#</p>#}
|
||||
<p>
|
||||
|
||||
<a class="btn btn-info"
|
||||
href="{{ path('fos_user_registration_register') }}">
|
||||
Créer un compte
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
{% block hwi_oauth_content %}
|
||||
<h1>oauth login</h1>
|
||||
{% if error is defined and error %}
|
||||
<span>{{ error }}</span>
|
||||
<div class="alert alert-danger pull-left">{{ error|trans }}</div>
|
||||
{% endif %}
|
||||
|
||||
<a class="btn btn-default btn-{{ "twitter" }}" href="{{ hwi_oauth_login_url("twitter") }}">
|
||||
<a class="btn btn-default btn-{{ "twitter" }}"
|
||||
href="{{ hwi_oauth_login_url("twitter") }}">
|
||||
<i class="fa fa-{{ "twitter" }}"></i>
|
||||
{{ "twitter" | trans({}, 'HWIOAuthBundle') }}
|
||||
</a>
|
||||
{#<a class="btn btn-default btn-{{ "google" }}" href="{{ hwi_oauth_login_url("google") }}">#}
|
||||
{#<i class="fa fa-{{ "google" }}"></i>#}
|
||||
{#{{ "google" | trans({}, 'HWIOAuthBundle') }}#}
|
||||
{#</a>#}
|
||||
|
||||
{#{% for owner in hwi_oauth_resource_owners() %}#}
|
||||
{#<a class="btn btn-default btn-block btn-{{ owner }}" href="{{ hwi_oauth_login_url(owner) }}">#}
|
||||
{#<i class="fa fa-{{ owner }}"></i>#}
|
||||
{#{{ owner | trans({}, 'HWIOAuthBundle') }}#}
|
||||
{#</a>#}
|
||||
{#<br/>#}
|
||||
{#{% endfor %}#}
|
||||
{% endblock hwi_oauth_content %}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% include 'default/footer.html.twig' %}
|
||||
{% endblock %}
|
||||
|
@ -14,6 +14,8 @@
|
||||
<form action="{{ path("fos_user_security_check") }}" method="post">
|
||||
{% if csrf_token is defined %}
|
||||
<input type="hidden" name="_csrf_token" value="{{ csrf_token }}"/>
|
||||
{% else %}
|
||||
PAS DE TOKEN CSRF
|
||||
{% endif %}
|
||||
|
||||
<label for="username">{{ 'security.login.username'|trans }}</label>
|
||||
@ -29,7 +31,6 @@
|
||||
|
||||
<input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans }}"/>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
{% block hwi_oauth_content %}
|
||||
@ -38,4 +39,4 @@
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock body %}
|
||||
{% endblock %}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% include 'default/header.html.twig' %}
|
||||
|
||||
|
||||
{% block body %}
|
||||
<div class="main-screen">
|
||||
<div id="welcome">
|
||||
<section class="bg-accessories">
|
||||
@ -17,10 +17,10 @@
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<div class="description">
|
||||
<strong> Votre caisse mobile dynamique en ligne </strong> Pensé pour les exposants
|
||||
et les créateurs divers en festival, cette caisse saura s'adapter à l'évolution de
|
||||
vos stocks et vous libèrera des affres de la fiche de compte à faire et compléter
|
||||
soi même.
|
||||
<strong> Votre caisse mobile dynamique en ligne </strong> Pensé pour les
|
||||
exposants et les créateurs divers en festival, cette caisse saura s'adapter à
|
||||
l'évolution de vos stocks et vous libèrera des affres de la fiche de compte à
|
||||
faire et compléter soi même.
|
||||
</div>
|
||||
<div class="try">
|
||||
<br>
|
||||
@ -33,8 +33,9 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<sub> Démonstration en vous connectant avec le login: <strong>demo</strong>
|
||||
et le mot de passe <strong>demo</strong>. </sub>
|
||||
<sub> Démonstration en vous connectant avec le login:
|
||||
<strong>demo</strong> et le mot de passe <strong>demo</strong>.
|
||||
</sub>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -59,12 +60,13 @@
|
||||
<fieldset class="bg-dark padded">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<a class="btn btn-primary" href="{{ path('dashboard') }}" class="btn btn-success">
|
||||
<a class="btn btn-primary" href="{{ path('dashboard') }}"
|
||||
class="btn btn-success">
|
||||
Essayez dès maintenant
|
||||
</a>
|
||||
<p>
|
||||
Démonstration en vous connectant avec le login: <strong>demo</strong> et le mot
|
||||
de passe <strong>demo</strong>.
|
||||
Démonstration en vous connectant avec le login: <strong>demo</strong> et le
|
||||
mot de passe <strong>demo</strong>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
@ -98,6 +100,7 @@
|
||||
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{% include 'default/footer.html.twig' %}
|
||||
{% endblock %}
|
||||
{% include 'default/footer.html.twig' %}
|
||||
|
||||
{% endblock %}
|
||||
|
@ -74,7 +74,7 @@ swiftmailer:
|
||||
#fos user bundle
|
||||
fos_user:
|
||||
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
|
||||
firewall_name: main
|
||||
firewall_name: secured_area
|
||||
user_class: AppBundle\Entity\User
|
||||
registration:
|
||||
confirmation:
|
||||
@ -108,17 +108,10 @@ hwi_oauth:
|
||||
# [using the referring URL for form login](http://symfony.com/doc/2.0/cookbook/security/form_login.html#using-the-referring-url).
|
||||
# use_referer: true
|
||||
resource_owners:
|
||||
google:
|
||||
type: google
|
||||
client_id: "%google_id%"
|
||||
client_secret: "%google_secret%"
|
||||
scope: "email"
|
||||
options:
|
||||
csrf: true
|
||||
# facebook:
|
||||
# type: facebook
|
||||
# client_id: "%facebook_id%"
|
||||
# client_secret: "%facebook_secret%"
|
||||
# google:
|
||||
# type: google
|
||||
# client_id: "%google_id%"
|
||||
# client_secret: "%google_secret%"
|
||||
# scope: "email"
|
||||
# options:
|
||||
# csrf: true
|
||||
@ -129,10 +122,10 @@ hwi_oauth:
|
||||
scope: "email"
|
||||
options:
|
||||
csrf: true
|
||||
disqus:
|
||||
type: disqus
|
||||
client_id: "%disqus_id%"
|
||||
client_secret: "%disqus_secret%"
|
||||
scope: "email"
|
||||
options:
|
||||
csrf: true
|
||||
# disqus:
|
||||
# type: disqus
|
||||
# client_id: "%disqus_id%"
|
||||
# client_secret: "%disqus_secret%"
|
||||
# scope: "email"
|
||||
# options:
|
||||
# csrf: true
|
||||
|
@ -9,7 +9,8 @@ hwi_oauth_redirect:
|
||||
hwi_oauth_connect:
|
||||
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
|
||||
prefix: /connect
|
||||
|
||||
fos_user:
|
||||
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
|
||||
#facebook_login:
|
||||
# path: /login/check-facebook
|
||||
|
||||
@ -21,7 +22,9 @@ disqus_login:
|
||||
|
||||
twitter_login:
|
||||
path: /login/check-twitter
|
||||
|
||||
app:
|
||||
resource: '@AppBundle/Controller/'
|
||||
type: annotation
|
||||
## app specific stuff
|
||||
app_festival:
|
||||
resource: "@AppBundle/Controller/FestivalController.php"
|
||||
@ -43,11 +46,7 @@ app_sell_record:
|
||||
resource: "@AppBundle/Controller/SellRecordController.php"
|
||||
type: annotation
|
||||
|
||||
app:
|
||||
resource: '@AppBundle/Controller/'
|
||||
type: annotation
|
||||
fos_user:
|
||||
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
|
||||
|
||||
|
||||
get_my_products:
|
||||
path: /get-my-products
|
||||
|
@ -9,18 +9,23 @@ security:
|
||||
id: fos_user.user_provider.username
|
||||
firewalls:
|
||||
secured_area:
|
||||
pattern: ^/
|
||||
anonymous: ~
|
||||
logout_on_user_change: true
|
||||
form_login:
|
||||
provider: fos_userbundle
|
||||
csrf_token_generator: security.csrf.token_manager
|
||||
default_target_path: dashboard
|
||||
logout:
|
||||
path: /logout
|
||||
target: /login
|
||||
anonymous: true
|
||||
logout_on_user_change: true
|
||||
oauth:
|
||||
resource_owners:
|
||||
# facebook: "/login/check-facebook"
|
||||
google: "/login/check-google"
|
||||
disqus: "/login/check-disqus"
|
||||
twitter: "/login/check-twitter"
|
||||
# my_custom_provider: "/login/check-custom"
|
||||
login_path: /login
|
||||
use_forward: false
|
||||
failure_path: /login
|
||||
@ -31,18 +36,6 @@ security:
|
||||
dev:
|
||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||
security: false
|
||||
|
||||
main:
|
||||
pattern: ^/
|
||||
form_login:
|
||||
provider: fos_userbundle
|
||||
csrf_token_generator: security.csrf.token_manager
|
||||
default_target_path: dashboard
|
||||
logout:
|
||||
path: /logout
|
||||
target: /login
|
||||
anonymous: true
|
||||
logout_on_user_change: true
|
||||
# https://symfony.com/doc/current/security/form_login_setup.html
|
||||
# activate different ways to authenticate
|
||||
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
|
||||
|
0
assets/css/fonts/all.scss
Normal file → Executable file
0
assets/css/fonts/all.scss
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SIL Open Font License.txt
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SIL Open Font License.txt
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Black.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Black.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-BlackIt.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-BlackIt.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Bold.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Bold.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-BoldIt.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-BoldIt.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-ExtraLight.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-ExtraLight.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-ExtraLightIt.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-ExtraLightIt.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-It.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-It.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Light.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Light.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-LightIt.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-LightIt.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Regular.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Regular.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Semibold.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-Semibold.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-SemiboldIt.otf
Normal file → Executable file
0
assets/css/fonts/source-sans-pro/SourceSansPro-SemiboldIt.otf
Normal file → Executable file
0
assets/css/pages/home.scss
Normal file → Executable file
0
assets/css/pages/home.scss
Normal file → Executable file
0
assets/img/accessories.jpg
Normal file → Executable file
0
assets/img/accessories.jpg
Normal file → Executable file
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 188 KiB |
0
assets/img/girl_computer.jpg
Normal file → Executable file
0
assets/img/girl_computer.jpg
Normal file → Executable file
Before Width: | Height: | Size: 247 KiB After Width: | Height: | Size: 247 KiB |
0
src/AppBundle/Entity/Festival.php
Normal file → Executable file
0
src/AppBundle/Entity/Festival.php
Normal file → Executable file
0
src/AppBundle/Entity/Product.php
Normal file → Executable file
0
src/AppBundle/Entity/Product.php
Normal file → Executable file
0
src/AppBundle/Entity/ProductCategory.php
Normal file → Executable file
0
src/AppBundle/Entity/ProductCategory.php
Normal file → Executable file
0
src/AppBundle/Entity/ProductSold.php
Normal file → Executable file
0
src/AppBundle/Entity/ProductSold.php
Normal file → Executable file
0
src/AppBundle/Entity/SellRecord.php
Normal file → Executable file
0
src/AppBundle/Entity/SellRecord.php
Normal file → Executable file
0
src/AppBundle/Entity/User.php
Normal file → Executable file
0
src/AppBundle/Entity/User.php
Normal file → Executable file
Loading…
Reference in New Issue
Block a user