Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- security:
- providers:
- my_ldap:
- ldap:
- service: ldap
- base_dn: ou=People,dc=insa-toulouse,dc=fr
- search_dn: ~
- search_password: ~
- default_roles: ROLE_USER
- uid_key: uid
- firewalls:
- dev:
- pattern: ^/(_(profiler|wdt)|css|images|js)/
- security: false
- login_firewall:
- pattern: ^/login$
- anonymous: ~
- main:
- logout:
- path: /logout
- form_login_ldap:
- login_path: login
- check_path: login_check
- service: ldap
- dn_string: 'uid={username},ou=People,dc=insa-toulouse,dc=fr'
- #anonymous: true
- #http_basic_ldap:
- # service: ldap
- # dn_string: 'uid={username},ou=People,dc=insa-toulouse,dc=fr'
- default:
- anonymous: ~
- services:
- ldap:
- class: SymfonyComponentLdapLdapClient
- arguments:
- - srv-ldap
- <?php
- namespace ClubInfoPizzaBundleController;
- use SymfonyBundleFrameworkBundleControllerController;
- use SymfonyComponentHttpFoundationRequest;
- use SensioBundleFrameworkExtraBundleConfigurationRoute;
- class SecurityController extends Controller
- {
- /**
- * @Route("/login", name="login")
- */
- public function loginAction(Request $request)
- {
- $authenticationUtils = $this->get('security.authentication_utils');
- // get the login error if there is one
- $error = $authenticationUtils->getLastAuthenticationError();
- // last username entered by the user
- $lastUsername = $authenticationUtils->getLastUsername();
- return $this->render(
- 'ClubInfoPizzaBundle:security:login.html.twig',
- array(
- // last username entered by the user
- 'last_username' => $lastUsername,
- 'error' => $error,
- )
- );
- }
- }
- {% if error %}
- <div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
- {% endif %}
- <form action="{{ path('login') }}" method="post">
- <label for="username">Username:</label>
- <input type="text" id="username" name="_username" value="{{ last_username }}" />
- <label for="password">Password:</label>
- <input type="password" id="password" name="_password" />
- {#
- If you want to control the URL the user
- is redirected to on success (more details below)
- <input type="hidden" name="_target_path" value="/account" />
- #}
- <button type="submit">login</button>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement