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;
|
||||
|
||||
use App\Http\Requests\StoreAliasRequest;
|
||||
use App\Http\Requests\UpdateAliasRequest;
|
||||
use App\Http\Resources\AliasResource;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
@ -22,7 +23,7 @@ class AliasController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function store()
|
||||
public function store(StoreAliasRequest $request)
|
||||
{
|
||||
if (user()->hasExceededNewAliasLimit()) {
|
||||
return response('', 429);
|
||||
|
@ -32,9 +33,9 @@ class AliasController extends Controller
|
|||
|
||||
$alias = user()->aliases()->create([
|
||||
'id' => $uuid,
|
||||
'email' => $uuid.'@'.config('anonaddy.domain'),
|
||||
'email' => $uuid.'@'.$request->domain,
|
||||
'local_part' => $uuid,
|
||||
'domain' => config('anonaddy.domain')
|
||||
'domain' => $request->domain
|
||||
]);
|
||||
|
||||
return new AliasResource($alias->fresh());
|
||||
|
|
|
@ -66,7 +66,7 @@ class RegisterController extends Controller
|
|||
],
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
'email:rfc,dns',
|
||||
'max:254',
|
||||
'confirmed',
|
||||
new RegisterUniqueRecipient
|
||||
|
|
|
@ -27,7 +27,7 @@ class EditDefaultRecipientRequest extends FormRequest
|
|||
return [
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
'email:rfc,dns',
|
||||
'max:254',
|
||||
'confirmed',
|
||||
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',
|
||||
'string',
|
||||
'max:254',
|
||||
'email',
|
||||
'email:rfc,dns',
|
||||
new UniqueRecipient
|
||||
]
|
||||
];
|
||||
|
|
|
@ -490,6 +490,10 @@
|
|||
<p class="mb-4">
|
||||
<b>86064c92-da41-443e-a2bf-5a7b0247842f@{{ domain }}</b>
|
||||
</p>
|
||||
<p>
|
||||
Useful if you do not wish to include your username in the email as a potential link
|
||||
between aliases.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -500,14 +504,47 @@
|
|||
>
|
||||
Generate new UUID alias
|
||||
</h2>
|
||||
|
||||
<p class="mt-4 text-grey-700">
|
||||
This will generate a new unique alias in the form of<br /><br />
|
||||
86064c92-da41-443e-a2bf-5a7b0247842f@{{ domain }}<br /><br />
|
||||
Useful if you do not wish to include your username in the email as a potential link
|
||||
between aliases.<br /><br />
|
||||
This will generate a new unique alias in the form of
|
||||
<span class="text-sm block mt-2 font-semibold"
|
||||
>86064c92-da41-443e-a2bf-5a7b0247842f@{{ domain }}</span
|
||||
>
|
||||
</p>
|
||||
|
||||
<p class="mt-2 text-grey-700">
|
||||
Other aliases e.g. alias@{{ subdomain }} are created automatically when they receive their
|
||||
first email.
|
||||
</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">
|
||||
<button
|
||||
@click="generateNewAlias"
|
||||
|
@ -658,6 +695,10 @@ export default {
|
|||
type: String,
|
||||
required: true,
|
||||
},
|
||||
allDomains: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
components: {
|
||||
Modal,
|
||||
|
@ -682,6 +723,7 @@ export default {
|
|||
editAliasRecipientsModalOpen: false,
|
||||
generateAliasModalOpen: false,
|
||||
generateAliasLoading: false,
|
||||
generateAliasDomain: this.domain,
|
||||
recipientsAliasToEdit: {},
|
||||
aliasRecipientsToEdit: [],
|
||||
}
|
||||
|
@ -805,9 +847,15 @@ export default {
|
|||
this.generateAliasLoading = true
|
||||
|
||||
axios
|
||||
.post('/aliases', JSON.stringify({}), {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
.post(
|
||||
'/aliases',
|
||||
JSON.stringify({
|
||||
domain: this.generateAliasDomain,
|
||||
}),
|
||||
{
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}
|
||||
)
|
||||
.then(({ data }) => {
|
||||
this.generateAliasLoading = false
|
||||
this.aliases.push(data.data)
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
<div class="container py-8">
|
||||
@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>
|
||||
@endsection
|
|
@ -146,7 +146,7 @@ class AliasesTest extends TestCase
|
|||
/** @test */
|
||||
public function user_can_generate_new_alias()
|
||||
{
|
||||
$response = $this->json('POST', '/aliases', []);
|
||||
$response = $this->json('POST', '/aliases', ['domain' => 'anonaddy.com']);
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertCount(1, $this->user->aliases);
|
||||
|
|
Loading…
Add table
Reference in a new issue