Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- security:
- encoders:
- administrators:
- class: NasivinAdminBundleEntityAdmin
- algorithm: plaintext
- role_hierarchy:
- ROLE_USER: ROLE_USER
- ROLE_ADMIN: ROLE_ADMIN
- ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
- providers:
- administrators:
- entity: { class: NasivinAdminBundle:Admin, property: username }
- firewalls:
- dev:
- pattern: ^/(_(profiler|wdt)|css|images|js)/
- security: false
- admin:
- pattern: ^/admin/
- provider: administrators
- anonymous: ~
- form_login:
- check_path: _admin_security_check
- login_path: _admin_login
- default_target_path: /admin/bla
- always_use_default_target_path: true
- logout:
- path: _admin_logout
- target: /admin
- access_control:
- #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- admin_login:
- path: ^/admin/login
- roles: IS_AUTHENTICATED_ANONYMOUSLY
- admin_area:
- path: ^/admin/.*
- roles: ROLE_USER
- <?php
- /**
- * Created by PhpStorm.
- * User: Michal
- * Date: 16.9.2014
- * Time: 11:37
- */
- namespace NasivinAdminBundleEntity;
- use SymfonyComponentSecurityCoreUserUserInterface;
- use DoctrineORMMapping as ORM;
- /**
- * NasivinAdminBundleEntityAdmin
- *
- * @ORMTable(name="tb_admin")
- * @ORMEntity()
- */
- class Admin implements UserInterface
- {
- /**
- * @ORMColumn(name="id", type="integer")
- * @ORMId
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORMColumn(name="username", type="string", length=25, unique=true)
- */
- protected $username;
- /**
- * @ORMColumn(name="password", type="string", length=64)
- */
- protected $password;
- /**
- * @ORMColumn(name="salt", type="string", length=64)
- */
- protected $salt;
- /**
- * @inheritDoc
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * @inheritDoc
- */
- public function getSalt()
- {
- // you *may* need a real salt depending on your encoder
- // see section on salt below
- return null;
- }
- /**
- * @inheritDoc
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * @inheritDoc
- */
- public function eraseCredentials()
- {
- }
- /**
- * @inheritDoc
- */
- public function getRoles()
- {
- return array("ROLE_ADMIN", "ROLE_USER");
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set username
- *
- * @param string $username
- * @return Admin
- */
- public function setUsername($username)
- {
- $this->username = $username;
- return $this;
- }
- /**
- * Set password
- *
- * @param string $password
- * @return Admin
- */
- public function setPassword($password)
- {
- $this->password = $password;
- return $this;
- }
- /**
- * Set salt
- *
- * @param string $salt
- * @return Admin
- */
- public function setSalt($salt)
- {
- $this->salt = $salt;
- return $this;
- }
- }
- {% extends "::base.html.twig" %}
- {% block title %}NasivinAdminBundle:Security:login{% endblock %}
- {% block body %}
- <h1>Welcome to the Security:login page</h1>
- <form action="{{ path('_admin_security_check') }}" method="post">
- <label for="username">Username:</label>
- <input type="text" id="username" name="_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>
- {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement