Skip to content

Create abrahem79@users.noreply.github.com#34

Open
abrahem79 wants to merge 1 commit into
auth0:mainfrom
abrahem79:patch-1
Open

Create abrahem79@users.noreply.github.com#34
abrahem79 wants to merge 1 commit into
auth0:mainfrom
abrahem79:patch-1

Conversation

@abrahem79

Copy link
Copy Markdown

> > use Auth0\Laravel\Facade\Auth0;
> > 
> > Route::get('/colors', function () {
> >   $endpoint = Auth0::management()->users();
> > 
> >   $colors = ['red', 'blue', 'green', 'black', 'white', 'yellow', 'purple', 'orange', 'pink', 'brown'];
> > 
> >   $endpoint->update(
> >     id: auth()->id(),
> >     body: [
> >         'user_metadata' => [
> >             'color' => $colors[random_int(0, count($colors) - 1)]
> >         ]
> >     ]
> >   );
> > 
> >   $metadata = $endpoint->get(auth()->id());
> >   $metadata = Auth0::json($metadata);
> > 
> >   $color = $metadata['user_metadata']['color'] ?? 'unknown';
> >   $name = auth()->user()->name;
> > 
> >   return response("Hello {$name}! Your favorite color is {$color}.");
> > })->middleware('auth');
> > 
> > ### Changes
> > 
> > <!--
> > Please describe what is changing, what you are adding, and/or why this is important. Include:
> > 
> > -   A summary if this is a new feature or template
> > -   Any alternative approaches considered
> > -->
> > 
> > -   [ ] I described the changes on this PR.
> > 
> > ### References
> > 
> > <!--
> > Please include relevant links supporting this change such as a:
> > 
> > -   support ticket
> > -   community post
> > -   StackOverflow post
> > -   support forum thread
> > -->
> > 
> > -   [ ] I added at least one link to explain why this change is needed.
> > 
> > ### Testing
> > 
> > <!--
> > Please describe how this can be tested by reviewers.
> > -->
> > 
> > **Steps to Reproduce**
> > 
> > -   Step 1 ...
> > -   Step 2 ...
> > 
> > ### Checklist
> > 
> > -   [ ] I have manually tested any new or updated actions templates in a real auth0 account.
> > -   [ ] This pull request's title matches the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#examples) format
> > -   [ ] This branch is up to date with `main`
> > -   [ ] All existing and new checks complete without errors
> > -   [ ] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
> > -   [ ] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
> > -   [ ] I have read the [Contribution guide](https://github.com/auth0/opensource-marketplace/blob/main/CONTRIBUTING.md) for this repository**
> ```
> 
> **
> 

use Auth0\Laravel\Facade\Auth0;

Route::get('/colors', function () {
  $endpoint = Auth0::management()->users();

  $colors = ['red', 'blue', 'green', 'black', 'white', 'yellow', 'purple', 'orange', 'pink', 'brown'];

  $endpoint->update(
    id: auth()->id(),
    body: [
        'user_metadata' => [
            'color' => $colors[random_int(0, count($colors) - 1)]
        ]
    ]
  );

  $metadata = $endpoint->get(auth()->id());
  $metadata = Auth0::json($metadata);

  $color = $metadata['user_metadata']['color'] ?? 'unknown';
  $name = auth()->user()->name;

  return response("Hello {$name}! Your favorite color is {$color}.");
})->middleware('auth');
@abrahem79
abrahem79 requested a review from a team as a code owner October 7, 2025 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant