Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Delivery
P
Public
Open source
konnect-bundle
Commits
45f85294
Commit
45f85294
authored
Sep 20, 2019
by
dbourdere
🤸
Browse files
oubli de push les derniere modif
parent
17ad6cb6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
83 deletions
+59
-83
Model/User.php
Model/User.php
+47
-78
Security/Provider/UserProvider.php
Security/Provider/UserProvider.php
+12
-5
No files found.
Model/User.php
View file @
45f85294
...
...
@@ -14,12 +14,9 @@ class User implements UserInterface, JsonSerializable
protected
$id
;
protected
$email
;
protected
$givenName
;
protected
$familyName
;
protected
$username
;
protected
$picture
;
protected
$locale
;
protected
$company
;
protected
$services
;
protected
$companyId
;
protected
$subscriptions
;
protected
$stripeCustomerId
;
protected
$roles
;
...
...
@@ -28,16 +25,6 @@ class User implements UserInterface, JsonSerializable
$this
->
roles
=
[
"ROLE_USER"
];
}
public
function
setServices
(
$services
)
{
$this
->
services
=
$services
;
}
public
function
getServices
()
{
return
$this
->
services
;
}
/**
* @return mixed
*/
...
...
@@ -57,44 +44,6 @@ class User implements UserInterface, JsonSerializable
return
$this
;
}
/**
* @return mixed
*/
public
function
getFamilyName
()
{
return
$this
->
familyName
;
}
/**
* @param mixed $familyName
*
* @return User
*/
public
function
setFamilyName
(
$familyName
):
User
{
$this
->
familyName
=
$familyName
;
return
$this
;
}
/**
* @return mixed
*/
public
function
getUsername
()
{
return
$this
->
username
;
}
/**
* @param mixed $username
*
* @return User
*/
public
function
setUsername
(
$username
):
User
{
$this
->
username
=
$username
;
return
$this
;
}
/**
* @param mixed $email
*
...
...
@@ -137,79 +86,81 @@ class User implements UserInterface, JsonSerializable
/**
* @return mixed
*/
public
function
get
Locale
()
public
function
get
CompanyId
()
{
return
$this
->
locale
;
return
$this
->
companyId
;
}
/**
* @param
mixed $locale
* @param
$companyId
*
* @return User
*/
public
function
set
Locale
(
$locale
):
User
public
function
set
CompanyId
(
$companyId
):
User
{
$this
->
locale
=
$locale
;
$this
->
companyId
=
$companyId
;
return
$this
;
}
/**
* @return mixed
*/
public
function
get
Company
()
public
function
get
StripeCustomerId
()
{
return
$this
->
company
;
return
$this
->
stripeCustomerId
;
}
/**
* @param mixed $company
*
* @param $stripeCustomerId
* @return User
*/
public
function
set
Company
(
$company
):
User
public
function
set
StripeCustomerId
(
$stripeCustomerId
):
User
{
$this
->
company
=
$company
;
$this
->
stripeCustomerId
=
$stripeCustomerId
;
return
$this
;
}
/**
* @return mixed
*/
public
function
get
StripeCustomer
Id
()
public
function
getId
()
{
return
$this
->
stripeCustomerI
d
;
return
$this
->
i
d
;
}
/**
* @param $stripeCustomerId
* @param mixed $id
*
* @return User
*/
public
function
set
StripeCustomerId
(
$stripeCustomerI
d
):
User
public
function
set
Id
(
$i
d
):
User
{
$this
->
stripeCustomerId
=
$stripeCustomerI
d
;
$this
->
id
=
$i
d
;
return
$this
;
}
/**
* @return mixed
*/
public
function
get
Id
()
public
function
get
Subscriptions
()
{
return
$this
->
id
;
return
$this
->
subscriptions
;
}
/**
* @param mixed $
id
* @param mixed $
subscriptions
*
* @return User
*/
public
function
set
Id
(
$id
):
User
public
function
set
Subscriptions
(
$subscriptions
)
{
$this
->
id
=
$id
;
$this
->
subscriptions
=
$subscriptions
;
return
$this
;
}
/**
* Returns the roles granted to the user.
*
...
...
@@ -274,6 +225,25 @@ class User implements UserInterface, JsonSerializable
return
$this
;
}
/**
* @return mixed
*/
public
function
getUsername
()
{
return
$this
->
username
;
}
/**
* @param mixed $username
*
* @return User
*/
public
function
setUsername
(
$username
):
User
{
$this
->
username
=
$username
;
return
$this
;
}
/**
* Specify data which should be serialized to JSON
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
...
...
@@ -287,11 +257,10 @@ class User implements UserInterface, JsonSerializable
"id"
=>
$this
->
getId
(),
"email"
=>
$this
->
getEmail
(),
"picture_url"
=>
$this
->
getPicture
(),
"locale"
=>
$this
->
getLocale
(),
"roles"
=>
$this
->
getRoles
(),
"
family_name
"
=>
$this
->
get
FamilyName
(),
"
company_id
"
=>
$this
->
get
CompanyId
(),
"given_name"
=>
$this
->
getGivenName
(),
"services"
=>
$this
->
getS
ervice
s
()
"services"
=>
$this
->
getS
ubscription
s
()
];
}
}
\ No newline at end of file
Security/Provider/UserProvider.php
View file @
45f85294
...
...
@@ -8,6 +8,7 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
use
HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface
;
use
Symfony\Component\Security\Core\Exception\UnsupportedUserException
;
use
HWI\Bundle\OAuthBundle\Security\Core\User\OAuthAwareUserProviderInterface
;
use
function
Couchbase\defaultDecoder
;
class
UserProvider
implements
UserProviderInterface
,
OAuthAwareUserProviderInterface
{
...
...
@@ -18,11 +19,16 @@ class UserProvider implements UserProviderInterface, OAuthAwareUserProviderInter
// `sub` is equal to the user id in Auth0
const
AUTH0_USER_DATA_KEY_ID
=
'sub'
;
const
AUTH0_USER_APP_METADATA_KEY
=
'http://konnect/metadata'
;
const
AUTH0_USER_APP_METADATA_KEY
=
'http://konnect/
app_
metadata'
;
const
AUTH0_USER_APP_METADATA_KEY_COMPANY
=
'company'
;
const
AUTH0_USER_APP_METADATA_KEY_COMPANY
ID
=
'company
_id
'
;
const
AUTH0_USER_APP_METADATA_KEY_STRIPE
=
'stripe_customer_id'
;
const
AUTH0_USER_APP_METADATA_KEY_ROLES
=
'roles'
;
const
AUTH0_USER_APP_METADATA_KEY_SUBSCRIPTIONS
=
'subscriptions'
;
const
AUTH0_USER_METADATA_KEY
=
'http://konnect/user_metadata'
;
const
AUTH0_USER_METADATA_KEY_GIVEN_NAME
=
'given_name'
;
/**
* {@inheritdoc}
...
...
@@ -41,11 +47,12 @@ class UserProvider implements UserProviderInterface, OAuthAwareUserProviderInter
{
$auth0ParsedObject
=
$response
->
getData
();
$user
=
new
User
(
$auth0ParsedObject
[
self
::
AUTH0_USER_DATA_KEY_ID
]);
$user
->
setUsername
(
$auth0ParsedObject
[
self
::
AUTH0_USER_DATA_KEY_NICKNAME
]);
$user
->
setEmail
(
$auth0ParsedObject
[
self
::
AUTH0_USER_DATA_KEY_EMAIL
]);
$user
->
setGivenName
(
explode
(
'@'
,
$user
->
getEmail
())[
0
]);
$user
->
setUsername
(
$auth0ParsedObject
[
self
::
AUTH0_USER_DATA_KEY_NICKNAME
]);
$user
->
setGivenName
(
$auth0ParsedObject
[
self
::
AUTH0_USER_METADATA_KEY
][
self
::
AUTH0_USER_METADATA_KEY_GIVEN_NAME
]
??
$auth0ParsedObject
[
self
::
AUTH0_USER_DATA_KEY_NICKNAME
]);
$user
->
setPicture
(
$auth0ParsedObject
[
self
::
AUTH0_USER_DATA_KEY_PICTURE
]);
$user
->
setCompany
(
$auth0ParsedObject
[
self
::
AUTH0_USER_APP_METADATA_KEY
][
self
::
AUTH0_USER_APP_METADATA_KEY_COMPANY
]);
$user
->
setCompanyId
(
$auth0ParsedObject
[
self
::
AUTH0_USER_APP_METADATA_KEY
][
self
::
AUTH0_USER_APP_METADATA_KEY_COMPANYID
]);
$user
->
setSubscriptions
(
$auth0ParsedObject
[
self
::
AUTH0_USER_APP_METADATA_KEY
][
self
::
AUTH0_USER_APP_METADATA_KEY_SUBSCRIPTIONS
]);
$user
->
setStripeCustomerId
(
$auth0ParsedObject
[
self
::
AUTH0_USER_APP_METADATA_KEY
][
self
::
AUTH0_USER_APP_METADATA_KEY_STRIPE
]);
$user
->
addRoles
(
$auth0ParsedObject
[
self
::
AUTH0_USER_APP_METADATA_KEY
][
self
::
AUTH0_USER_APP_METADATA_KEY_ROLES
]);
return
$user
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment