Sunday 15 August 2010

php - Security.yml file is wrong, can't get users from the database -



php - Security.yml file is wrong, can't get users from the database -

i have troubles security.yml file:

# can read more security in related section of documentation # http://symfony.com/doc/current/book/security.html security: # http://symfony.com/doc/current/book/security.html#encoding-the-user-s-password encoders: #symfony\component\security\core\user\user: plaintext login\loginbundle\entity\user: sha512 # http://symfony.com/doc/current/book/security.html#hierarchical-roles role_hierarchy: role_admin: role_user role_super_admin: [role_user, role_admin, role_allowed_to_switch] # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers providers: users: entity: { class: loginloginbundle:user, property: username } in_memory: memory: users: user: { password: userpass, roles: [ 'role_user' ] } admin: { password: adminpass, roles: [ 'role_admin' ] } # main part of security, can set firewalls # specific sections of app firewalls: secured_area: pattern: ^/ anonymous: ~ form_login: provider: users login_path: login check_path: login_check access_control: - { path: ^/login, roles: is_authenticated_anonymously }

i have website has login form. users located in database. can login username: user , password: userpass how can work users database?

i have read userinterfaces , fooled around it, without succes.

maybe user entity helpfull, here is:

<?php namespace login\loginbundle\entity; utilize doctrine\orm\mapping orm; utilize symfony\component\security\core\user\userinterface; /** * user */ class user implements userinterface, \serializable { /** * @var string */ private $username; /** * @var string */ private $email; /** * @var string */ private $password; /** * @var integer */ private $money; /** * @var integer */ private $userid; /** * @var \login\loginbundle\entity\team */ private $teamteamid; /** * @inheritdoc */ public function getsalt() { // *may* need real salt depending on encoder // see section on salt below homecoming null; } /** * @inheritdoc */ public function getroles() { homecoming array('role_user'); } /** * @inheritdoc */ public function erasecredentials() { } /** * @see \serializable::serialize() */ public function serialize() { homecoming serialize(array( $this->id, $this->username, $this->password, // see section on salt below // $this->salt, )); } /** * @see \serializable::unserialize() */ public function unserialize($serialized) { list ( $this->id, $this->username, $this->password, // see section on salt below // $this->salt ) = unserialize($serialized); } /** * set username * * @param string $username * @return user */ public function setusername($username) { $this->username = $username; homecoming $this; } /** * username * * @return string */ public function getusername() { homecoming $this->username; } /** * set email * * @param string $email * @return user */ public function setemail($email) { $this->email = $email; homecoming $this; } /** * email * * @return string */ public function getemail() { homecoming $this->email; } /** * set password * * @param string $password * @return user */ public function setpassword($password) { $this->password = $password; homecoming $this; } /** * password * * @return string */ public function getpassword() { homecoming $this->password; } /** * set money * * @param integer $money * @return user */ public function setmoney($money) { $this->money = $money; homecoming $this; } /** * money * * @return integer */ public function getmoney() { homecoming $this->money; } /** * userid * * @return integer */ public function getuserid() { homecoming $this->userid; } /** * set teamteamid * * @param \login\loginbundle\entity\team $teamteamid * @return user */ public function setteamteamid(\login\loginbundle\entity\team $teamteamid = null) { $this->teamteamid = $teamteamid; homecoming $this; } /** * teamteamid * * @return \login\loginbundle\entity\team */ public function getteamteamid() { homecoming $this->teamteamid; } }

what proper way edit security.yml file , acces database users?

php symfony2

No comments:

Post a Comment