UserBundle of AWHSPanel
This bundle provides basic authentication.
Have installed the foundation
- Clone this bundle inside
src/AWHS/
directory. - Enable the bundle in the kernel by adding the following line right after
//AWHS Bundles
inapp/AppKernel.php
file:
new AWHS\UserBundle\AWHSUserBundle(),
- Append the following configuration to the
app/config.yml
file:
#UserBundle Configuration
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: AWHS\UserBundle\Entity\User
group:
group_class: AWHS\UserBundle\Entity\Group
profile:
form:
type: AWHS\UserBundle\Form\Type\ProfileFormType
registration:
form:
type: AWHS\UserBundle\Form\Type\RegistrationFormType
- Append the following routing to the
app/routing.yml
file:
#FOSUserBundle
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
fos_user_group:
resource: "@FOSUserBundle/Resources/config/routing/group.xml"
prefix: /group
#UserBundle
awhs_user:
resource: "@AWHSUserBundle/Resources/config/routing.yml"
prefix: /
- Configure the
app/security.yml
file as follow:
# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
# if you are using Symfony < 2.8, use the following config instead:
# csrf_provider: form.csrf_provider
logout: true
anonymous: true
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 }
- Update database & clear cache:
php bin/console doctrine:schema:update --force; php bin/console cache:clear; php bin/console cache:clear --env=prod
You may have to set permissions back to www-datachown -R www-data:www-data /usr/local/awhspanel/panel/*
- Create your first user:
php bin/console fos:user:create yourUsername [email protected] yourPassword
- Give your user admin privilege :
php bin/console fos:user:promote yourUsername ROLE_ADMIN
- Multilingual
- Refactoring old code.