Skip to content

Commit

Permalink
partial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
glena committed May 22, 2015
1 parent ac3dcb2 commit 8be40ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions lib/WP_Auth0_UserCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

class WP_Auth0_UserCreator {

public function tokenHasRequiredScopes($jwt) {

return (
(isset($jwt->email) || isset($jwt->nickname))
&& isset(identities)
);

}

public function create($userinfo, $token) {

// If the user doesn't exist we need to either create a new one, or asign him to an existing one
Expand Down
10 changes: 8 additions & 2 deletions lib/WP_Auth0_UsersRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ public static function getUser($jwt, $encodedJWT) {

if ($response['response']['code'] != 200) return null;

$auth0User = json_decode($response['body']);
$creator = new WP_Auth0_UserCreator();

if ($creator->tokenHasRequiredScopes($jwt->email)) {
$auth0User = $jwt
}
else {
$auth0User = json_decode($response['body']);
}

try {
$creator = new WP_Auth0_UserCreator();
$user_id = $creator->create($auth0User,$encodedJWT);

return new WP_User($user_id);
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ License URI: https://github.com/auth0/wp-auth0/blob/master/LICENSE.md
Stable tag: trunk
Contributors: hrajchert, rrauch

Single Sign On for Enterprises + Social Login + User/Passwords. For all your WorpdPress instances. Powered by Auth0.
Single Sign On for Enterprises + Social Login + User/Passwords. For all your WordPress instances. Powered by Auth0.

== Description ==

Expand Down

0 comments on commit 8be40ca

Please sign in to comment.