-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Domain\Shop\Models\License; | ||
use Illuminate\Support\Str; | ||
|
||
class RegenerateLicenseKeyController | ||
{ | ||
public function __invoke(License $license) | ||
{ | ||
if (! $license->isAssignedTo(current_user())) { | ||
abort(403, "License {$license->id} is not assigned to user id" . current_user()->id); | ||
} | ||
|
||
$license->update([ | ||
'key' => Str::random(64), | ||
]); | ||
|
||
flash()->success('License key regenerated.'); | ||
|
||
return redirect()->back(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,16 @@ class="fa-secondary" | |
class="fa-primary" | ||
fill="currentColor" | ||
d="M96 392V96H24a24 24 0 0 0-24 24v368a24 24 0 0 0 24 24h272a24 24 0 0 0 24-24v-40H152a56.06 56.06 0 0 1-56-56zM441 73L375 7a24 24 0 0 0-17-7h-6v96h96v-6.06A24 24 0 0 0 441 73z"></path></g></svg></span></code> | ||
<form | ||
x-data | ||
@submit.prevent="if (confirm('Are you sure you want to regenerate this license key?')) $el.submit()" | ||
class="mt-2" | ||
action="{{ route('regenerate-key', $license) }}" | ||
method="POST" | ||
> | ||
@csrf | ||
<button type="submit" class="underline">Regenerate key</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
|
@@ -212,11 +222,6 @@ class="px-6 flex justify-between items-center text-xs py-4 border-b border-gray- | |
</div> | ||
</section> | ||
|
||
@once | ||
@push('scripts') | ||
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script> | ||
@endpush | ||
@endonce | ||
@push('scripts') | ||
<script type="text/javascript"> | ||
function copyLicense(element, licenseKey) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters