Added UUID domain options
This commit is contained in:
parent
7b0ac3aed4
commit
e005cefbd5
8 changed files with 99 additions and 15 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Requests\StoreAliasRequest;
|
||||||
use App\Http\Requests\UpdateAliasRequest;
|
use App\Http\Requests\UpdateAliasRequest;
|
||||||
use App\Http\Resources\AliasResource;
|
use App\Http\Resources\AliasResource;
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
|
@ -22,7 +23,7 @@ class AliasController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store()
|
public function store(StoreAliasRequest $request)
|
||||||
{
|
{
|
||||||
if (user()->hasExceededNewAliasLimit()) {
|
if (user()->hasExceededNewAliasLimit()) {
|
||||||
return response('', 429);
|
return response('', 429);
|
||||||
|
@ -32,9 +33,9 @@ class AliasController extends Controller
|
||||||
|
|
||||||
$alias = user()->aliases()->create([
|
$alias = user()->aliases()->create([
|
||||||
'id' => $uuid,
|
'id' => $uuid,
|
||||||
'email' => $uuid.'@'.config('anonaddy.domain'),
|
'email' => $uuid.'@'.$request->domain,
|
||||||
'local_part' => $uuid,
|
'local_part' => $uuid,
|
||||||
'domain' => config('anonaddy.domain')
|
'domain' => $request->domain
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return new AliasResource($alias->fresh());
|
return new AliasResource($alias->fresh());
|
||||||
|
|
|
@ -66,7 +66,7 @@ class RegisterController extends Controller
|
||||||
],
|
],
|
||||||
'email' => [
|
'email' => [
|
||||||
'required',
|
'required',
|
||||||
'email',
|
'email:rfc,dns',
|
||||||
'max:254',
|
'max:254',
|
||||||
'confirmed',
|
'confirmed',
|
||||||
new RegisterUniqueRecipient
|
new RegisterUniqueRecipient
|
||||||
|
|
|
@ -27,7 +27,7 @@ class EditDefaultRecipientRequest extends FormRequest
|
||||||
return [
|
return [
|
||||||
'email' => [
|
'email' => [
|
||||||
'required',
|
'required',
|
||||||
'email',
|
'email:rfc,dns',
|
||||||
'max:254',
|
'max:254',
|
||||||
'confirmed',
|
'confirmed',
|
||||||
new RegisterUniqueRecipient,
|
new RegisterUniqueRecipient,
|
||||||
|
|
35
app/Http/Requests/StoreAliasRequest.php
Normal file
35
app/Http/Requests/StoreAliasRequest.php
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class StoreAliasRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'domain' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
Rule::in(config('anonaddy.all_domains'))
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,7 +29,7 @@ class StoreRecipientRequest extends FormRequest
|
||||||
'required',
|
'required',
|
||||||
'string',
|
'string',
|
||||||
'max:254',
|
'max:254',
|
||||||
'email',
|
'email:rfc,dns',
|
||||||
new UniqueRecipient
|
new UniqueRecipient
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
@ -490,6 +490,10 @@
|
||||||
<p class="mb-4">
|
<p class="mb-4">
|
||||||
<b>86064c92-da41-443e-a2bf-5a7b0247842f@{{ domain }}</b>
|
<b>86064c92-da41-443e-a2bf-5a7b0247842f@{{ domain }}</b>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
Useful if you do not wish to include your username in the email as a potential link
|
||||||
|
between aliases.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -500,14 +504,47 @@
|
||||||
>
|
>
|
||||||
Generate new UUID alias
|
Generate new UUID alias
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<p class="mt-4 text-grey-700">
|
<p class="mt-4 text-grey-700">
|
||||||
This will generate a new unique alias in the form of<br /><br />
|
This will generate a new unique alias in the form of
|
||||||
86064c92-da41-443e-a2bf-5a7b0247842f@{{ domain }}<br /><br />
|
<span class="text-sm block mt-2 font-semibold"
|
||||||
Useful if you do not wish to include your username in the email as a potential link
|
>86064c92-da41-443e-a2bf-5a7b0247842f@{{ domain }}</span
|
||||||
between aliases.<br /><br />
|
>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="mt-2 text-grey-700">
|
||||||
Other aliases e.g. alias@{{ subdomain }} are created automatically when they receive their
|
Other aliases e.g. alias@{{ subdomain }} are created automatically when they receive their
|
||||||
first email.
|
first email.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<label for="banner_location" class="block text-grey-700 text-sm my-2">
|
||||||
|
Alias Domain:
|
||||||
|
</label>
|
||||||
|
<div class="block relative w-full">
|
||||||
|
<select
|
||||||
|
v-model="generateAliasDomain"
|
||||||
|
class="block appearance-none w-full text-grey-700 bg-grey-100 p-3 pr-8 rounded shadow focus:shadow-outline"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<option v-for="domainOption in allDomains" :key="domainOption" :value="domainOption">{{
|
||||||
|
domainOption
|
||||||
|
}}</option>
|
||||||
|
</select>
|
||||||
|
<div
|
||||||
|
class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="fill-current h-4 w-4"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<button
|
<button
|
||||||
@click="generateNewAlias"
|
@click="generateNewAlias"
|
||||||
|
@ -658,6 +695,10 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
allDomains: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Modal,
|
Modal,
|
||||||
|
@ -682,6 +723,7 @@ export default {
|
||||||
editAliasRecipientsModalOpen: false,
|
editAliasRecipientsModalOpen: false,
|
||||||
generateAliasModalOpen: false,
|
generateAliasModalOpen: false,
|
||||||
generateAliasLoading: false,
|
generateAliasLoading: false,
|
||||||
|
generateAliasDomain: this.domain,
|
||||||
recipientsAliasToEdit: {},
|
recipientsAliasToEdit: {},
|
||||||
aliasRecipientsToEdit: [],
|
aliasRecipientsToEdit: [],
|
||||||
}
|
}
|
||||||
|
@ -805,9 +847,15 @@ export default {
|
||||||
this.generateAliasLoading = true
|
this.generateAliasLoading = true
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.post('/aliases', JSON.stringify({}), {
|
.post(
|
||||||
headers: { 'Content-Type': 'application/json' },
|
'/aliases',
|
||||||
})
|
JSON.stringify({
|
||||||
|
domain: this.generateAliasDomain,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}
|
||||||
|
)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
this.generateAliasLoading = false
|
this.generateAliasLoading = false
|
||||||
this.aliases.push(data.data)
|
this.aliases.push(data.data)
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
<div class="container py-8">
|
<div class="container py-8">
|
||||||
@include('shared.status')
|
@include('shared.status')
|
||||||
|
|
||||||
<aliases :default-recipient="{{json_encode($defaultRecipient)}}" :initial-aliases="{{json_encode($aliases)}}" :recipient-options="{{json_encode($recipients)}}" :total-forwarded="{{$totalForwarded}}" :total-blocked="{{$totalBlocked}}" :total-replies="{{$totalReplies}}" domain="{{config('anonaddy.domain')}}" subdomain="{{$domain}}" :bandwidth-mb="{{$bandwidthMb}}" :month="{{ json_encode(now()->format('M')) }}" />
|
<aliases :default-recipient="{{json_encode($defaultRecipient)}}" :initial-aliases="{{json_encode($aliases)}}" :recipient-options="{{json_encode($recipients)}}" :total-forwarded="{{$totalForwarded}}" :total-blocked="{{$totalBlocked}}" :total-replies="{{$totalReplies}}" domain="{{config('anonaddy.domain')}}" subdomain="{{$domain}}" :bandwidth-mb="{{$bandwidthMb}}" :month="{{json_encode(now()->format('M'))}}" :all-domains="{{json_encode(config('anonaddy.all_domains'))}}" />
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
|
@ -146,7 +146,7 @@ class AliasesTest extends TestCase
|
||||||
/** @test */
|
/** @test */
|
||||||
public function user_can_generate_new_alias()
|
public function user_can_generate_new_alias()
|
||||||
{
|
{
|
||||||
$response = $this->json('POST', '/aliases', []);
|
$response = $this->json('POST', '/aliases', ['domain' => 'anonaddy.com']);
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
$this->assertCount(1, $this->user->aliases);
|
$this->assertCount(1, $this->user->aliases);
|
||||||
|
|
Loading…
Add table
Reference in a new issue