refactoring de Name & Email vers Service & Account

This commit is contained in:
Bubka 2020-01-06 21:45:14 +01:00
parent 1a53aeed33
commit 9e7ea7d0fb
11 changed files with 53 additions and 53 deletions

View File

@ -33,18 +33,18 @@ public function decode(Request $request)
$options[$option[0]] = $option[1];
}
$email = $service = '';
$account = $service = '';
$serviceChunks = explode(':', str_replace('otpauth://totp/', '', $uriChunks[0]));
if( count($serviceChunks) > 1 ) {
$email = $serviceChunks[1];
$account = $serviceChunks[1];
}
$service = $serviceChunks[0];
if( strstr( $service, '@') ) {
$email = $service;
$account = $service;
$service = '';
}
@ -53,8 +53,8 @@ public function decode(Request $request)
}
$twofaccount = (object) array(
'name' => $service,
'email' => $email,
'service' => $service,
'account' => $account,
'uri' => $uri,
'icon' => '',
'options' => $options

View File

@ -30,8 +30,8 @@ public function index()
public function store(Request $request)
{
$twofaccount = TwoFAccount::create([
'name' => $request->name,
'email' => $request->email,
'service' => $request->service,
'account' => $request->account,
'uri' => $request->uri,
'icon' => $request->icon
]);

View File

@ -9,7 +9,7 @@ class TwoFAccount extends Model
{
use SoftDeletes;
protected $fillable = ['name', 'email', 'uri', 'icon'];
protected $fillable = ['service', 'account', 'uri', 'icon'];
/**

View File

@ -19,8 +19,8 @@
$factory->define(TwoFAccount::class, function (Faker $faker) {
return [
'name' => $faker->unique()->domainName,
'email' => $faker->safeEmail,
'service' => $faker->unique()->domainName,
'account' => $faker->safeEmail,
'uri' => 'otpauth://totp/' . $faker->email . '?secret=' . $faker->regexify('[A-Z0-9]{16}') . '&issuer=test',
];
});

View File

@ -15,9 +15,9 @@ public function up()
{
Schema::create('twofaccounts', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('service');
$table->string('uri');
$table->string('email');
$table->string('account');
$table->string('icon')->nullable();
$table->timestamps();
$table->softDeletes();

View File

@ -14,32 +14,32 @@ public function run()
$faker = \Faker\Factory::create();
TwoFAccount::create([
'name' => $faker->unique()->domainName,
'email' => $faker->email,
'service' => $faker->unique()->domainName,
'account' => $faker->email,
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFTVVRBGY7UIW&issuer=test',
'icon' => 'https://fakeimg.pl/64x64/'
]);
TwoFAccount::create([
'name' => $faker->unique()->domainName,
'email' => $faker->email,
'service' => $faker->unique()->domainName,
'account' => $faker->email,
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHYVRBGY7UIW&issuer=test',
'icon' => 'https://fakeimg.pl/64x64/'
]);
TwoFAccount::create([
'name' => $faker->unique()->domainName,
'email' => $faker->email,
'service' => $faker->unique()->domainName,
'account' => $faker->email,
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHZVRBGY7UIW&issuer=test',
'icon' => 'https://fakeimg.pl/64x64/'
]);
TwoFAccount::create([
'name' => $faker->unique()->domainName,
'email' => $faker->email,
'service' => $faker->unique()->domainName,
'account' => $faker->email,
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVIRBGY7UIW&issuer=test',
'icon' => 'https://fakeimg.pl/64x64/'
]);
TwoFAccount::create([
'name' => $faker->unique()->domainName,
'email' => $faker->email,
'service' => $faker->unique()->domainName,
'account' => $faker->email,
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVVOBGY7UIW&issuer=test',
'icon' => 'https://fakeimg.pl/64x64/'
]);

View File

@ -3,8 +3,8 @@
<figure class="image is-64x64" style="display: inline-block">
<img :src="icon">
</figure>
<p class="is-size-4 has-text-grey-light">{{ name }}</p>
<p class="is-size-6 has-text-grey">{{ email }}</p>
<p class="is-size-4 has-text-grey-light">{{ service }}</p>
<p class="is-size-6 has-text-grey">{{ account }}</p>
<slot></slot>
<div class="modal-action-links has-text-grey">
<router-link :to="{ name: 'edit', params: { twofaccountId: twofaccountid }}">Edit</router-link>
@ -18,6 +18,6 @@
return {
}
},
props: ['twofaccountid', 'name', 'email', 'icon'],
props: ['twofaccountid', 'service', 'account', 'icon'],
}
</script>

View File

@ -5,8 +5,8 @@
<span v-for="account in accounts" class="button is-black twofaccount" >
<span @click.stop="getAccount(account.id)">
<img :src="account.icon">
{{ account.name }}
<span class="is-family-primary is-size-7 has-text-grey">{{ account.email }}</span>
{{ account.service }}
<span class="is-family-primary is-size-7 has-text-grey">{{ account.account }}</span>
</span>
<a v-on:click="deleteAccount(account.id)">Delete</a>
</span>
@ -15,9 +15,9 @@
<modal v-model="ShowTwofaccountInModal">
<twofaccount-show
:twofaccountid='twofaccount.id'
:name='twofaccount.name'
:service='twofaccount.service'
:icon='twofaccount.icon'
:email='twofaccount.email'>
:account='twofaccount.account'>
<one-time-password ref="OneTimePassword"></one-time-password>
</twofaccount-show>
</modal>
@ -48,8 +48,8 @@
response.data.forEach((data) => {
this.accounts.push({
id : data.id,
name : data.name,
email : data.email,
service : data.service,
account : data.account,
icon : data.icon
})
})
@ -77,8 +77,8 @@
axios.get('api/twofaccounts/' + id).then(response => {
this.twofaccount.id = response.data.id
this.twofaccount.name = response.data.name
this.twofaccount.email = response.data.email
this.twofaccount.service = response.data.service
this.twofaccount.account = response.data.account
this.twofaccount.icon = response.data.icon
this.$refs.OneTimePassword.AccountId = response.data.id

View File

@ -20,13 +20,13 @@
<div class="field">
<label class="label">Service</label>
<div class="control">
<input class="input" type="text" placeholder="Name" v-model="twofaccount.name" required autofocus />
<input class="input" type="text" placeholder="Service" v-model="twofaccount.service" required autofocus />
</div>
</div>
<div class="field">
<label class="label">Email</label>
<label class="label">Account</label>
<div class="control">
<input class="input" type="text" placeholder="Email" v-model="twofaccount.email" />
<input class="input" type="text" placeholder="Email" v-model="twofaccount.account" />
</div>
</div>
<div class="field">
@ -73,8 +73,8 @@
data() {
return {
twofaccount: {
'name' : '',
'email' : '',
'service' : '',
'account' : '',
'uri' : '',
'icon' : ''
}

View File

@ -7,13 +7,13 @@
<div class="field">
<label class="label">Service</label>
<div class="control">
<input class="input" type="text" placeholder="Account name" v-model="twofaccount.name" required autofocus />
<input class="input" type="text" placeholder="Service" v-model="twofaccount.service" required autofocus />
</div>
</div>
<div class="field">
<label class="label">Email</label>
<label class="label">Account</label>
<div class="control">
<input class="input" type="text" placeholder="account email" v-model="twofaccount.email" />
<input class="input" type="text" placeholder="Account" v-model="twofaccount.account" />
</div>
</div>
<div class="field">

View File

@ -32,14 +32,14 @@ public function testTwoFAccountCreation()
{
$response = $this->actingAs($this->user, 'api')
->json('POST', '/api/twofaccounts', [
'name' => 'testCreation',
'email' => 'test@example.org',
'service' => 'testCreation',
'account' => 'test@example.org',
'uri' => 'test',
])
->assertStatus(201)
->assertJson([
'name' => 'testCreation',
'email' => 'test@example.org',
'service' => 'testCreation',
'account' => 'test@example.org',
'uri' => 'test',
]);
}
@ -53,8 +53,8 @@ public function testTwoFAccountCreation()
public function testTOTPgeneration()
{
$twofaccount = factory(TwoFAccount::class)->create([
'name' => 'testTOTP',
'email' => 'test@test.com',
'service' => 'testTOTP',
'account' => 'test@test.com',
'uri' => 'otpauth://totp/test@test.com?secret=A4GRFHVVRBGY7UIW&issuer=test'
]);
@ -78,15 +78,15 @@ public function testTwoFAccountUpdate()
$response = $this->actingAs($this->user, 'api')
->json('PUT', '/api/twofaccounts/' . $twofaccount->id, [
'name' => 'testUpdate',
'email' => 'testUpdate@test.com',
'service' => 'testUpdate',
'account' => 'testUpdate@test.com',
'uri' => 'testUpdate',
])
->assertStatus(200)
->assertJson([
'id' => 1,
'name' => 'testUpdate',
'email' => 'testUpdate@test.com',
'service' => 'testUpdate',
'account' => 'testUpdate@test.com',
'uri' => 'testUpdate',
'icon' => null,
]);
@ -108,8 +108,8 @@ public function testTwoFAccountIndexListing()
->assertJsonStructure([
'*' => [
'id',
'name',
'email',
'service',
'account',
'uri',
'icon',
'created_at',