Example #1
0
 /**
  * @param string $userId
  * @return mixed
  */
 public function findOne($userId)
 {
     if ('' != $userId) {
         return ApiUsers::get(Yii::$app->getModule('auth0')->domain, Yii::$app->getModule('auth0')->apiTokens['usersRead'], $userId);
     }
     return false;
 }
Example #2
0
 /**
  * Updathes the user metadata. This end up calling the path /users/{id_user}
  * To delete an attribute, just set it null. ie: [ 'old_attr' => null ]
  * It will only update the existing attrs and keep the others untouch
  * for more info:
  *       https://auth0.com/docs/apiv2#!/users/patch_users_by_id
  *
  * @return User data
  */
 public function updateUserMetadata($metadata)
 {
     $user = ApiUsers::update($this->domain, $this->getIdToken(), $this->user["user_id"], array('user_metadata' => $metadata));
     $this->setUser($user);
 }
Example #3
0
 public function privatePing()
 {
     $userData = \Auth0\SDK\Api\ApiUsers::get(getenv('AUTH0_DOMAIN'), $this->token, $this->tokenInfo->sub);
     return array("status" => 'ok', "message" => 'Shh, it\' secret', "user" => array("email" => $userData["email"], "username" => $userData["username"]));
 }
Example #4
0
 /**
  * @return ApiUsers[]|array
  */
 public function all()
 {
     return ApiUsers::search(Yii::$app->getModule('auth0')->domain, Yii::$app->getModule('auth0')->apiTokens['usersRead'], $this->params);
 }
 /**
  * Get the Auth0 User Profile based on the JWT (and validate it).
  *
  * @return User info as described in https://docs.auth0.com/user-profile
  */
 public function getUserProfileByA0UID($jwt, $a0UID)
 {
     return ApiUsers::get($this->domain, $jwt, $a0UID);
 }
Example #6
0
 /**
  * @param string $userId
  * @param string $data
  * @return mixed
  */
 protected function update($userId, $data)
 {
     return ApiUsers::update(Yii::$app->getModule('auth0')->domain, Yii::$app->getModule('auth0')->apiTokens['usersUpdate'], $userId, $data);
 }
Example #7
0
$store = new SessionStore();
$main_user = $store->get('user');
if (!$main_user) {
    header("Location: /linkuser.php");
    exit;
}
$auth0_config = array('domain' => getenv('AUTH0_DOMAIN'), 'client_id' => getenv('AUTH0_CLIENT_ID'), 'client_secret' => getenv('AUTH0_CLIENT_SECRET'), 'redirect_uri' => getenv('AUTH0_CALLBACK_URL'), 'persist_user' => false, 'persist_id_token' => false, 'store' => false);
$auth0Oauth = new \Auth0\SDK\Auth0($auth0_config);
$secondary_user = $auth0Oauth->getUser();
if ($secondary_user) {
    $app_token = getenv('AUTH0_APPTOKEN');
    $domain = getenv('AUTH0_DOMAIN');
    echo '<pre>';
    echo "Main user: "******"user_id"] . "\n";
    echo "Main user: "******"user_id"] . "\n";
    var_dump(\Auth0\SDK\API\ApiUsers::linkAccount($domain, $app_token, $main_user["user_id"], array("provider" => $secondary_user["identities"][0]["provider"], "user_id" => $secondary_user["identities"][0]["user_id"])));
    echo '</pre>';
    exit;
}
?>

<html>
    <head>
        <script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
        <script src="https://cdn.auth0.com/js/lock-7.min.js"></script>

        <script type="text/javascript" src="//use.typekit.net/iws6ohy.js"></script>
        <script type="text/javascript">try{Typekit.load();}catch(e){}</script>

        <meta name="viewport" content="width=device-width, initial-scale=1">
<?php

if (isset($_REQUEST['create'])) {
    $app_token = getenv('AUTH0_APPTOKEN');
    $domain = getenv('AUTH0_DOMAIN');
    $email = $_REQUEST['email'];
    $password = $_REQUEST['password'];
    $color = $_REQUEST['color'];
    echo '<pre>';
    var_dump(\Auth0\SDK\API\ApiUsers::create($domain, $app_token, array('email' => $email, 'password' => $password, 'connection' => 'Username-Password-Authentication', 'user_metadata' => array('color' => $color))));
    echo '</pre>';
}
?>


<form action="?create-user" method="POST">

    <label for="email">Email</label>
    <input type="email" name="email" id="email" />

    <label for="password">Password</label>
    <input type="password" name="password" id="password" />

    <label for="color">Color</label>
    <input type="color" name="color" id="color" />

    <input type="submit" name="create" value="Create" />

</form>