nedwave/user-bundle

User management for Symfony2. Compatible with Doctrine ORM

Installs: 391

Dependents: 2

Stars: 10

Watchers: 4

Forks: 5

Open Issues: 1

Language: PHP

v2.3.3 2015-06-18 11:58 UTC

README

User management for Symfony2. Compatible with Doctrine ORM

Features:

Installation

Install package with composer

"nedwave/user-bundle": "*"

Register bundles in AppKernel

new Nedwave\MandrillBundle\NedwaveMandrillBundle(),
new Nedwave\UserBundle\NedwaveUserBundle(),

Extend the User Entity from the bundle

<?php

namespace Acme\DemoBundle\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

use Nedwave\UserBundle\Entity\User as BaseUser;

/**
 * @ORM\Table(name="users")
 * @ORM\Entity()
 */
class User extends BaseUser
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
}

Update config.yml

# Nedwave User Bundle
nedwave_user:
    user_class: Acme\DemoBundle\Entity\User # Your user class
    firewall_name: main

nedwave_mandrill:
    api_key: %mandrill_api_key%
    default:
        sender: info@nedwave.com # Your sender e-mail
        sender_name: Nedwave # Your sender name

Update parameters.yml and fill in your app settings

mandrill_api_key: <secret>

Update parameters.yml.dist

mandrill_api_key: ~

Update security.yml

security:
    encoders:
        Acme\DemoBundle\Entity\User: sha512 # Your user class

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    access_decision_manager:
        strategy: unanimous

    providers:
        doctrine:
            id: nedwave_user.user_provider

    firewalls:            
        main:
            pattern:    ^/
            anonymous:  ~
            context: application
            form_login:
                login_path:  login
                check_path:  login_check

            logout:
                path:   logout
                target: /

    access_control:
        - { path: ^/%locale%/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/%locale%/password/reset, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/%locale%/password/request, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/%locale%/password/change, role: IS_AUTHENTICATED_FULLY }
        - { path: ^/%locale%/dashboard, role: IS_AUTHENTICATED_FULLY }

Update routing.yml

nedwave_user:
    resource: "@NedwaveUserBundle/Resources/config/routing.yml"
    prefix:   /