gpt4 book ai didi

php - 替换 sylius 中的身份验证层和用户实体

转载 作者:搜寻专家 更新时间:2023-10-31 21:30:00 26 4
gpt4 key购买 nike

我创建了一个 symfony2 项目并使用了自定义身份验证提供程序 (http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html)。我的新任务是在 sylius 中创建一个电子商务应用程序,它应该与我当前的 symfony2 项目一起工作。我想将我当前在 symfony2 项目中的用户表作为 sylius 中的用户提供者...是否可以创建这样的项目...因为 fosUserBundlefosOauthServer bundel安装在 sylius 中,我如何使用我的自定义身份验证机制覆盖这些包

我的symfony2项目配置如下所述

我在 security.yml 中尝试了以下内容

 security:
encoders:
AppBundle\Entity\Users:
algorithm: bcrypt

providers:
our_db_provider:
entity:
class: AppBundle:Users

api_key_user_provider:
id: api_key_user_provider


firewalls:
dev:
pattern: ^/(_(profiler|wdt|error)|css|images|js)/
security: false

api:
pattern: ^/api
stateless: true
simple_preauth:
authenticator: apikey_authenticator
provider: api_key_user_provider

web:
anonymous: ~
http_basic: ~
provider: our_db_provider
form_login:
login_path: /login
check_path: /login_check

这是我的用户类

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* Users
*
* @ORM\Table(name="users", uniqueConstraints= {@ORM\UniqueConstraint(name="users_user_name_unique", columns={"user_name"}), @ORM\UniqueConstraint(name="users_xmpp_password_unique", columns= {"xmpp_password"})})
* @ORM\Entity(repositoryClass="AppBundle\Entity\UsersRepository")
*/


class Users implements UserInterface, \Serializable {

/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;

/**
* @var integer
*
* @ORM\Column(name="parent_id", type="integer", nullable=false)
*/
private $parentId;

/**
* @var string
*
* @ORM\Column(name="first_name", type="string", length=100, nullable=false)
*/
private $firstName;

/**
* @var string
*
* @ORM\Column(name="last_name", type="string", length=100, nullable=false)
*/
private $lastName;

/**
* @var string
*
* @ORM\Column(name="user_name", type="string", length=120, nullable=false)
*/
private $userName;

/**
* @var string
*
* @ORM\Column(name="reg_type", type="string", length=20, nullable=false)
*/
private $regType;

/**
* @var string
*
* @ORM\Column(name="oauth_uid", type="string", length=255, nullable=false)
*/
private $oauthUid;

/**
* @var boolean
*
* @ORM\Column(name="active", type="boolean", nullable=false)
*/
private $active;

/**
* @var string
*
* @ORM\Column(name="email", type="string", length=100, nullable=false)
*/
private $email;

/**
* @var string
*
* @ORM\Column(name="password", type="string", length=150, nullable=false)
*/
private $password;

/**
* @var string
*
* @ORM\Column(name="xmpp_password", type="string", length=20, nullable=false)
*/
private $xmppPassword;

/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private $createdAt = '0000-00-00 00:00:00';

/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=false)
*/
private $updatedAt = '0000-00-00 00:00:00';

/**
* @var \DateTime
*
* @ORM\Column(name="deleted_at", type="datetime", nullable=true)
*/
private $deletedAt;

/**
* @var string
*
* @ORM\Column(name="activation_code", type="string", length=50, nullable=true)
*/
private $activationCode;

/**
* @var string
*
* @ORM\Column(name="user_profile_pic", type="string", length=200, nullable=false)
*/
private $userProfilePic = 'uploads/defaults/user/profile_pic.jpg';

/**
* @var string
*
* @ORM\Column(name="user_timeline_pic", type="string", length=200, nullable=false)
*/
private $userTimelinePic = 'uploads/defaults/user/timeline_pic.jpg';

/**
* @var string
*
* @ORM\Column(name="country", type="string", length=50, nullable=false)
*/
private $country;

/**
* @var string
*
* @ORM\Column(name="state", type="string", length=50, nullable=false)
*/
private $state;

/**
* @var string
*
* @ORM\Column(name="city", type="string", length=50, nullable=false)
*/
private $city;

/**
* @var string
*
* @ORM\Column(name="hobbies", type="string", length=100, nullable=false)
*/
private $hobbies;

/**
* @var string
*
* @ORM\Column(name="interests", type="string", length=100, nullable=false)
*/
private $interests;

/**
* @var string
*
* @ORM\Column(name="about", type="string", length=500, nullable=false)
*/
private $about;

/**
* @var boolean
*
* @ORM\Column(name="gender", type="boolean", nullable=false)
*/
private $gender;

/**
* @var \DateTime
*
* @ORM\Column(name="dob", type="date", nullable=false)
*/
private $dob;

/**
* @var integer
*
* @ORM\Column(name="quickblox_id", type="integer", nullable=false)
*/
private $quickbloxId;

/**
* @var boolean
*
* @ORM\Column(name="privacy", type="boolean", nullable=false)
*/
private $privacy = '0';

/**
* @var string
*
* @ORM\Column(name="school", type="string", length=255, nullable=false)
*/
private $school;

/**
* @var string
*
* @ORM\Column(name="college", type="string", length=255, nullable=false)
*/
private $college;

/**
* @var string
*
* @ORM\Column(name="work", type="string", length=255, nullable=false)
*/
private $work;

/**
* @var string
*
* @ORM\Column(name="relationship_status", type="string", length=50, nullable=false)
*/
private $relationshipStatus;



public function getSalt() {
// you *may* need a real salt depending on your encoder
// see section on salt below
return null;
}



public function getRoles() {
return array('ROLE_API');
}

public function eraseCredentials() {

}

/** @see \Serializable::serialize() */
public function serialize() {
return serialize(array(
$this->id,
$this->email,
// see section on salt below
// $this->salt,
));
}

/** @see \Serializable::unserialize() */
public function unserialize($serialized) {
list (
$this->id,
$this->email,
// see section on salt below
// $this->salt
) = unserialize($serialized);
}

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

/**
* Set parentId
*
* @param integer $parentId
* @return Users
*/
public function setParentId($parentId) {
$this->parentId = $parentId;

return $this;
}

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

/**
* Set firstName
*
* @param string $firstName
* @return Users
*/
public function setFirstName($firstName) {
$this->firstName = $firstName;

return $this;
}

/**
* Get firstName
*
* @return string
*/
public function getFirstName() {
return $this->firstName;
}

/**
* Set lastName
*
* @param string $lastName
* @return Users
*/
public function setLastName($lastName) {
$this->lastName = $lastName;

return $this;
}

/**
* Get lastName
*
* @return string
*/
public function getLastName() {
return $this->lastName;
}

/**
* Set userName
*
* @param string $userName
* @return Users
*/
public function setUserName($userName) {
$this->userName = $userName;

return $this;
}

/**
* Get userName
*
* @return string
*/
public function getUserName() {
return $this->email;
}

/**
* Set regType
*
* @param string $regType
* @return Users
*/
public function setRegType($regType) {
$this->regType = $regType;

return $this;
}

/**
* Get regType
*
* @return string
*/
public function getRegType() {
return $this->regType;
}

/**
* Set oauthUid
*
* @param string $oauthUid
* @return Users
*/
public function setOauthUid($oauthUid) {
$this->oauthUid = $oauthUid;

return $this;
}

/**
* Get oauthUid
*
* @return string
*/
public function getOauthUid() {
return $this->oauthUid;
}

/**
* Set active
*
* @param boolean $active
* @return Users
*/
public function setActive($active) {
$this->active = $active;

return $this;
}

/**
* Get active
*
* @return boolean
*/
public function getActive() {
return $this->active;
}

/**
* Set email
*
* @param string $email
* @return Users
*/
public function setEmail($email) {
$this->email = $email;

return $this;
}

/**
* Get email
*
* @return string
*/
public function getEmail() {
return $this->email;
}

/**
* Set password
*
* @param string $password
* @return Users
*/
public function setPassword($password) {
$this->password = $password;

return $this;
}

/**
* Get password
*
* @return string
*/
public function getPassword() {
return $this->password;
}

/**
* Set xmppPassword
*
* @param string $xmppPassword
* @return Users
*/
public function setXmppPassword($xmppPassword) {
$this->xmppPassword = $xmppPassword;

return $this;
}

/**
* Get xmppPassword
*
* @return string
*/
public function getXmppPassword() {
return $this->xmppPassword;
}

/**
* Set createdAt
*
* @param \DateTime $createdAt
* @return Users
*/
public function setCreatedAt($createdAt) {
$this->createdAt = $createdAt;

return $this;
}

/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt() {
return $this->createdAt;
}

/**
* Set updatedAt
*
* @param \DateTime $updatedAt
* @return Users
*/
public function setUpdatedAt($updatedAt) {
$this->updatedAt = $updatedAt;

return $this;
}

/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt() {
return $this->updatedAt;
}

/**
* Set deletedAt
*
* @param \DateTime $deletedAt
* @return Users
*/
public function setDeletedAt($deletedAt) {
$this->deletedAt = $deletedAt;

return $this;
}

/**
* Get deletedAt
*
* @return \DateTime
*/
public function getDeletedAt() {
return $this->deletedAt;
}

/**
* Set activationCode
*
* @param string $activationCode
* @return Users
*/
public function setActivationCode($activationCode) {
$this->activationCode = $activationCode;

return $this;
}

/**
* Get activationCode
*
* @return string
*/
public function getActivationCode() {
return $this->activationCode;
}

/**
* Set userProfilePic
*
* @param string $userProfilePic
* @return Users
*/
public function setUserProfilePic($userProfilePic) {
$this->userProfilePic = $userProfilePic;

return $this;
}

/**
* Get userProfilePic
*
* @return string
*/
public function getUserProfilePic() {
return $this->userProfilePic;
}

/**
* Set userTimelinePic
*
* @param string $userTimelinePic
* @return Users
*/
public function setUserTimelinePic($userTimelinePic) {
$this->userTimelinePic = $userTimelinePic;

return $this;
}

/**
* Get userTimelinePic
*
* @return string
*/
public function getUserTimelinePic() {
return $this->userTimelinePic;
}

/**
* Set country
*
* @param string $country
* @return Users
*/
public function setCountry($country) {
$this->country = $country;

return $this;
}

/**
* Get country
*
* @return string
*/
public function getCountry() {
return $this->country;
}

/**
* Set state
*
* @param string $state
* @return Users
*/
public function setState($state) {
$this->state = $state;

return $this;
}

/**
* Get state
*
* @return string
*/
public function getState() {
return $this->state;
}

/**
* Set city
*
* @param string $city
* @return Users
*/
public function setCity($city) {
$this->city = $city;

return $this;
}

/**
* Get city
*
* @return string
*/
public function getCity() {
return $this->city;
}

/**
* Set hobbies
*
* @param string $hobbies
* @return Users
*/
public function setHobbies($hobbies) {
$this->hobbies = $hobbies;

return $this;
}

/**
* Get hobbies
*
* @return string
*/
public function getHobbies() {
return $this->hobbies;
}

/**
* Set interests
*
* @param string $interests
* @return Users
*/
public function setInterests($interests) {
$this->interests = $interests;

return $this;
}

/**
* Get interests
*
* @return string
*/
public function getInterests() {
return $this->interests;
}

/**
* Set about
*
* @param string $about
* @return Users
*/
public function setAbout($about) {
$this->about = $about;

return $this;
}

/**
* Get about
*
* @return string
*/
public function getAbout() {
return $this->about;
}

/**
* Set gender
*
* @param boolean $gender
* @return Users
*/
public function setGender($gender) {
$this->gender = $gender;

return $this;
}

/**
* Get gender
*
* @return boolean
*/
public function getGender() {
return $this->gender;
}

/**
* Set dob
*
* @param \DateTime $dob
* @return Users
*/
public function setDob($dob) {
$this->dob = $dob;

return $this;
}

/**
* Get dob
*
* @return \DateTime
*/
public function getDob() {
return $this->dob;
}

/**
* Set quickbloxId
*
* @param integer $quickbloxId
* @return Users
*/
public function setQuickbloxId($quickbloxId) {
$this->quickbloxId = $quickbloxId;

return $this;
}

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

/**
* Set privacy
*
* @param boolean $privacy
* @return Users
*/
public function setPrivacy($privacy) {
$this->privacy = $privacy;

return $this;
}

/**
* Get privacy
*
* @return boolean
*/
public function getPrivacy() {
return $this->privacy;
}

/**
* Set school
*
* @param string $school
* @return Users
*/
public function setSchool($school) {
$this->school = $school;

return $this;
}

/**
* Get school
*
* @return string
*/
public function getSchool() {
return $this->school;
}

/**
* Set college
*
* @param string $college
* @return Users
*/
public function setCollege($college) {
$this->college = $college;

return $this;
}

/**
* Get college
*
* @return string
*/
public function getCollege() {
return $this->college;
}

/**
* Set work
*
* @param string $work
* @return Users
*/
public function setWork($work) {
$this->work = $work;

return $this;
}

/**
* Get work
*
* @return string
*/
public function getWork() {
return $this->work;
}

/**
* Set relationshipStatus
*
* @param string $relationshipStatus
* @return Users
*/
public function setRelationshipStatus($relationshipStatus) {
$this->relationshipStatus = $relationshipStatus;

return $this;
}

/**
* Get relationshipStatus
*
* @return string
*/
public function getRelationshipStatus() {
return $this->relationshipStatus;
}

最佳答案

您可以在这里找到答案https://github.com/Sylius/Sylius/issues/2931 .

关于php - 替换 sylius 中的身份验证层和用户实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31041587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com