Code Monkey home page Code Monkey logo

userbundle's Introduction

[LEGACY] UserBundle

abandoned!

Use FOS user instead.

Configuration

# app/config/config.yml

krg_user:
    registration:
        confirmed_target_route: homepage 
    login:
        admin_target_route: easyadmin
        user_target_route: homepage

doctrine:
    dbal:
        types:
            gender_enum: KRG\UserBundle\Doctrine\DBAL\GenderEnum
    resolve_target_entities:
        KRG\UserBundle\Entity\UserInterface: AppBundle\Entity\User
# app/config/routing.yml

krg_user:
    resource: "@KRGUserBundle/Controller/"
    type:     annotation
    prefix:   /
# app/config/security.yml

security:
    providers:
        email_provider:
            entity: { class: KRG\UserBundle\Entity\UserInterface, property: emailCanonical }
        invitation_token_provider:
            entity: { class: KRG\UserBundle\Entity\UserInterface, property: invitationToken }
            
    firewalls:
        ...
        guess:
            pattern:    ^/guess
            anonymous:  ~
            logout:     ~
            context:    main
            guard:
                provider: invitation_token_provider
                authenticators: [KRG\UserBundle\Security\Authenticator\TokenAuthenticator]
                    
        main:
            pattern:     ^/
            logout:      true
            anonymous:   true
            switch_user: true
            access_denied_handler: KRG\UserBundle\Security\Firewall\AccessDeniedHandler
            form_login:
                provider: email_provider
                default_target_path: /
                login_path: krg_user_login
                check_path: krg_user_login_check
                csrf_token_generator: security.csrf.token_manager
                success_handler: KRG\UserBundle\Security\Firewall\AuthenticationSuccessHandler

User entity

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="`user`")
 */
class User extends \KRG\UserBundle\Entity\User
{
}

Admin

EasyAdmin configuration:

# app/config/admin.yml

parameters:
    krg_cms.user.class: 'AppBundle\Entity\User'

imports:
    - { resource: '@KRGUserBundle/Resources/config/easyadmin/*.yml' }

Override form type

<?php

namespace AppBundle\Form\Type;

use Symfony\Component\Form\FormBuilderInterface;

class RegistrationType extends \KRG\UserBundle\Form\Type\RegistrationType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
    }
}
services:
    AppBundle\Form\Type\RegistrationType:
        decorates: KRG\UserBundle\Form\Type\RegistrationType

PrivateData annotation

PrivateData annotation reset property value on softDelete.

Usage:

<?php

use KRG\UserBundle\Annotation\PrivateData;

class User 
{
    /**
     * @PrivateData(replaceWith="John")
     * @ORM\Column(type="string", nullable=true)
     */
    protected $firstname;

    /**
     * @PrivateData(domain="kangourouge.com")
     * @ORM\Column(type="string", unique=true)
     */
    protected $email;
}

userbundle's People

Contributors

arthur-min avatar chafiq avatar atomatis avatar t00m4s avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

Forkers

t00m4s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.