Fix #104 Return validation URL when creation an account creation request token

This commit is contained in:
Timothée Jaussoin 2023-05-23 17:07:57 +02:00
parent 1e5052da1d
commit ca4320e734
2 changed files with 10 additions and 0 deletions

View file

@ -27,9 +27,17 @@ class AccountCreationRequestToken extends Model
use HasFactory;
protected $hidden = ['id', 'updated_at', 'created_at'];
protected $appends = ['validation_url'];
public function accountCreationToken()
{
return $this->belongsTo(AccountCreationToken::class, 'acc_creation_token_id');
}
public function getValidationUrlAttribute(): ?string
{
return $this->validated_at == null
? route('account.creation_request_token.check', $this->token)
: null;
}
}

View file

@ -148,6 +148,8 @@ class ApiAccountCreationTokenTest extends TestCase
$response->assertStatus(201);
$creationRequestToken = $response->json()['token'];
$this->assertSame($response->json()['validation_url'], route('account.creation_request_token.check', $creationRequestToken));
// Validate the creation request token
AccountCreationRequestToken::where('token', $creationRequestToken)->update(['validated_at' => Carbon::now()]);