Clase 15 FOS

1,239 views

Published on

www.hydrascs.com

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,239
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Clase 15 FOS

  1. 1. FOSUserBundle Realizada por: Christian Aquino |@cj_aquino Diego Ramirez |@thedarsideofit Gonzalo Alonso |@GonzaloAlonsoD Diego Barros |@Inmzombie Para: Hydras C&S |@hydras_cs Basada en Libro Symfony 2 en español Nacho Pacheco y The Book
  2. 2. ¿Qué es FOSUser? FOSUserBundle actúa en la parte superior del marco de seguridad proporcionado por Symfony, para que este sea rápido y fácil de almacenar usuarios en una base de datos.
  3. 3. Instalando FOSUser { "require": { "friendsofsymfony/user-bundle": "*" } } $ php composer.phar update friendsofsymfony/user-bundle
  4. 4. <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new FOSUserBundleFOSUserBundle(), ); }
  5. 5. <?php // src/Acme/UserBundle/Entity/User.php namespace AcmeUserBundleEntity; use FOSUserBundleEntityUser as BaseUser; use DoctrineORMMapping as ORM; /** * @ORMEntity * @ORMTable(name="fos_user") */ class User extends BaseUser
  6. 6. { /** * @ORMId * @ORMColumn(type="integer") * @ORMGeneratedValue(strategy="AUTO") */ protected $id; public function __construct() { parent::__construct(); } }
  7. 7. # app/config/security.yml security: encoders: FOSUserBundleModelUserInterface: sha512 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: ROLE_ADMIN providers: fos_userbundle: id: fos_user.user_provider.username
  8. 8. firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider logout: true anonymous: true
  9. 9. access_control: - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/admin/, role: ROLE_ADMIN }
  10. 10. # app/config/config.yml fos_user: db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel' firewall_name: main user_class: AcmeUserBundleEntityUser
  11. 11. # app/config/routing.yml fos_user_security: resource: "@FOSUserBundle/Resources/config/routing/sec urity.xml" fos_user_profile: resource: "@FOSUserBundle/Resources/config/routing/prof ile.xml" prefix: /profile
  12. 12. fos_user_register: resource: "@FOSUserBundle/Resources/config/routing/regi stration.xml" prefix: /register fos_user_resetting: resource: "@FOSUserBundle/Resources/config/routing/rese tting.xml" prefix: /resetting
  13. 13. fos_user_change_password: resource: "@FOSUserBundle/Resources/config/routing/cha nge_password.xml" prefix: /profile
  14. 14. $ php app/console doctrine:schema:update -- force https://github.com/FriendsOfSymfony/FOSUserBundle

×