cleanup, validation

This commit is contained in:
spencerrlongg 2023-11-15 20:29:14 -06:00
parent 6c6417e595
commit 9cf81c7ad4
3 changed files with 9 additions and 38 deletions

View file

@ -23,12 +23,13 @@ class PersonalAccessTokens extends Component
{ {
return [ return [
'name' => 'required|string|max:255', 'name' => 'required|string|max:255',
'scopes' => 'nullable|array',
]; ];
} }
public function createToken(): void public function createToken(): void
{ {
$this->validate();
$newToken = Auth::user()->createToken($this->name); $newToken = Auth::user()->createToken($this->name);
$this->newTokenString = $newToken->accessToken; $this->newTokenString = $newToken->accessToken;

View file

@ -1,29 +0,0 @@
<div class="modal fade" id="modal-access-token" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button " class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
Personal Access Token
</h4>
</div>
<div class="modal-body">
<p>
Here is your new personal access token. This is the only time it will be shown so don't lose it!
You may now use this token to make API requests.
</p>
<pre><code>
{{-- {{ accessToken }}--}}
</code></pre>
</div>
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

View file

@ -72,17 +72,15 @@
<div class="modal-body"> <div class="modal-body">
<!-- Form Errors --> <!-- Form Errors -->
@if($errors === true) @if($errors->has('name'))
<div class="alert alert-danger" <div class="alert alert-danger"
{{-- v-if="form.errors.length > 0"--}}
> >
<p><strong>Whoops!</strong> Something went wrong!</p> <p><strong>Whoops!</strong> Something went wrong!</p>
<br> <br>
<ul> <ul>
<li <li
{{-- v-for="error in form.errors"--}}
> >
{{-- {{ error }}--}} @error('name') <span class="error">{{ $message }}</span> @enderror
</li> </li>
</ul> </ul>
</div> </div>
@ -90,7 +88,6 @@
<!-- Create Token Form --> <!-- Create Token Form -->
<form class="form-horizontal" role="form" <form class="form-horizontal" role="form"
{{-- @submit.prevent="store"--}}
> >
<!-- Name --> <!-- Name -->
<div class="form-group"> <div class="form-group">
@ -98,13 +95,15 @@
<div class="col-md-6"> <div class="col-md-6">
<input id="create-token-name" type="text" aria-label="name" class="form-control" name="name" <input id="create-token-name" type="text" aria-label="name" class="form-control" name="name"
{{-- defer because it's submitting if i don't --}} {{-- defer because it's submitting as i type if i don't --}}
wire:model.defer="name" wire:model.defer="name"
> >
</div> </div>
</div> </div>
<!-- Scopes --> <!-- Scopes -->
{{-- Seems like scopes was never working, I couldn't figure out how to enable the feature if it was --}}
{{-- <div class="form-group"--}} {{-- <div class="form-group"--}}
{{-- v-if="scopes.length > 0"--}} {{-- v-if="scopes.length > 0"--}}
{{-- >--}} {{-- >--}}
@ -163,7 +162,7 @@
</p> </p>
<pre><code> <pre><code>
{{ $newTokenString }} {{ e($newTokenString) }}
</code></pre> </code></pre>
</div> </div>