mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-22 00:03:09 +01:00
secret property now named uri to match otphp wording
This commit is contained in:
parent
bb4fbfd46e
commit
e7695b64bc
@ -31,7 +31,7 @@ public function store(Request $request)
|
||||
{
|
||||
$twofaccount = TwoFAccount::create([
|
||||
'name' => $request->name,
|
||||
'secret' => $request->secret
|
||||
'uri' => $request->uri
|
||||
]);
|
||||
|
||||
return response()->json($twofaccount, 201);
|
||||
@ -59,7 +59,7 @@ public function show(TwoFAccount $twofaccount)
|
||||
public function generateTOTP(TwoFAccount $twofaccount)
|
||||
{
|
||||
try {
|
||||
$otp = Factory::loadFromProvisioningUri($twofaccount->secret);
|
||||
$otp = Factory::loadFromProvisioningUri($twofaccount->uri);
|
||||
} catch (InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => 'Error generating TOTP',
|
||||
|
@ -9,7 +9,7 @@ class TwoFAccount extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = ['name', 'secret', 'icon'];
|
||||
protected $fillable = ['name', 'uri', 'icon'];
|
||||
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ public function up()
|
||||
Schema::create('twofaccounts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('secret');
|
||||
$table->string('uri');
|
||||
$table->string('icon')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
@ -17,26 +17,26 @@ public function run()
|
||||
|
||||
TwoFAccount::create([
|
||||
'name' => $faker->unique()->domainName,
|
||||
'secret' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test',
|
||||
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test',
|
||||
]);
|
||||
|
||||
$deletedResource = TwoFAccount::create([
|
||||
'name' => $faker->unique()->domainName,
|
||||
'secret' => $faker->password,
|
||||
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test',
|
||||
]);
|
||||
$deletedResource->delete();
|
||||
|
||||
TwoFAccount::create([
|
||||
'name' => $faker->unique()->domainName,
|
||||
'secret' => $faker->password,
|
||||
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test',
|
||||
]);
|
||||
TwoFAccount::create([
|
||||
'name' => $faker->unique()->domainName,
|
||||
'secret' => $faker->password,
|
||||
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test',
|
||||
]);
|
||||
TwoFAccount::create([
|
||||
'name' => $faker->unique()->domainName,
|
||||
'secret' => $faker->password,
|
||||
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ public function testTwoFAccountCreation()
|
||||
$response = $this->actingAs($user, 'api')
|
||||
->json('POST', '/api/twofaccounts', [
|
||||
'name' => 'testCreation',
|
||||
'secret' => 'test',
|
||||
'uri' => 'test',
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJson([
|
||||
'name' => 'testCreation',
|
||||
'secret' => 'test',
|
||||
'uri' => 'test',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -62,11 +62,11 @@ public function testTOTPgeneration()
|
||||
|
||||
$twofaccount = TwoFAccount::create([
|
||||
'name' => 'testTOTP',
|
||||
'secret' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test'
|
||||
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test'
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user, 'api')
|
||||
->json('POST', '/api/twofaccounts/' . $twofaccount->id . '/totp')
|
||||
->json('GET', '/api/twofaccounts/' . $twofaccount->id . '/totp')
|
||||
->assertStatus(200)
|
||||
->assertJsonStructure([
|
||||
'totp',
|
||||
@ -86,13 +86,13 @@ public function testTwoFAccountUpdate()
|
||||
$response = $this->actingAs($user, 'api')
|
||||
->json('PUT', '/api/twofaccounts/1', [
|
||||
'name' => 'testUpdate',
|
||||
'secret' => 'testUpdate',
|
||||
'uri' => 'testUpdate',
|
||||
])
|
||||
->assertStatus(200)
|
||||
->assertJson([
|
||||
'id' => 1,
|
||||
'name' => 'testUpdate',
|
||||
'secret' => 'testUpdate',
|
||||
'uri' => 'testUpdate',
|
||||
'icon' => null,
|
||||
]);
|
||||
}
|
||||
@ -114,7 +114,7 @@ public function testTwoFAccountIndexListing()
|
||||
'*' => [
|
||||
'id',
|
||||
'name',
|
||||
'secret',
|
||||
'uri',
|
||||
'icon',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
@ -135,7 +135,7 @@ public function testTwoFAccountDeletion()
|
||||
|
||||
$twofaccount = TwoFAccount::create([
|
||||
'name' => 'testDelete',
|
||||
'secret' => 'test'
|
||||
'uri' => 'test'
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user, 'api')
|
||||
@ -154,7 +154,7 @@ public function testTwoFAccountPermanentDeletion()
|
||||
|
||||
$twofaccount = TwoFAccount::create([
|
||||
'name' => 'testHardDelete',
|
||||
'secret' => 'test'
|
||||
'uri' => 'test'
|
||||
]);
|
||||
|
||||
$twofaccount->delete();
|
||||
|
Loading…
Reference in New Issue
Block a user