Skip to content

Commit f879470

Browse files
committed
remove forced encryption
1 parent b7dca56 commit f879470

File tree

5 files changed

+83
-79
lines changed

5 files changed

+83
-79
lines changed

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</source>
3636
<php>
3737
<env name="APP_ENV" value="testing"/>
38-
<env name="BCRYPT_ROUNDS" value="4"/>
38+
<env name="BCRYPT_ROUNDS" value="12"/>
3939
<env name="CACHE_DRIVER" value="array"/>
4040
<env name="DB_CONNECTION" value="sqlite"/>
4141
<env name="DB_DATABASE" value=":memory:"/>

src/app/Http/Controllers/Auth/RegisterController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Http\Request;
88
use Illuminate\Routing\Controller;
99
use Illuminate\Support\Facades\Cookie;
10+
use Illuminate\Support\Facades\Hash;
1011
use Illuminate\Support\Facades\Validator;
1112

1213
class RegisterController extends Controller
@@ -76,7 +77,7 @@ protected function create(array $data)
7677
return $user->create([
7778
'name' => $data['name'],
7879
backpack_authentication_column() => $data[backpack_authentication_column()],
79-
'password' => bcrypt($data['password']),
80+
'password' => Hash::make($data['password']),
8081
]);
8182
}
8283

tests/Unit/CrudPanel/CrudPanelCreateTest.php

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Faker\Factory;
1414
use Illuminate\Database\Eloquent\Relations\Relation;
1515
use Illuminate\Support\Arr;
16+
use Illuminate\Support\Facades\Hash;
1617

1718
/**
1819
* @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Create
@@ -132,7 +133,7 @@ public function testCreate()
132133
$inputData = [
133134
'name' => $faker->name,
134135
'email' => $faker->safeEmail,
135-
'password' => bcrypt($faker->password()),
136+
'password' => Hash::make($faker->password()),
136137
];
137138

138139
$entry = $this->crudPanel->create($inputData);
@@ -152,7 +153,7 @@ public function testCreateWithOneToOneRelationship()
152153
$inputData = [
153154
'name' => $faker->name,
154155
'email' => $faker->safeEmail,
155-
'password' => bcrypt($faker->password()),
156+
'password' => Hash::make($faker->password()),
156157
'accountDetails' => [
157158
'nickname' => $account_details_nickname,
158159
'profile_picture' => 'test.jpg',
@@ -184,7 +185,7 @@ public function testCreateWithOneToOneRelationshipUsingRepeatableInterface()
184185
$inputData = [
185186
'name' => $faker->name,
186187
'email' => $faker->safeEmail,
187-
'password' => bcrypt($faker->password()),
188+
'password' => Hash::make($faker->password()),
188189
'accountDetails' => [
189190
['nickname' => $account_details_nickname, 'profile_picture' => 'test.jpg'],
190191
],
@@ -251,7 +252,7 @@ public function testCreateWithManyToManyRelationship()
251252
$inputData = [
252253
'name' => $faker->name,
253254
'email' => $faker->safeEmail,
254-
'password' => bcrypt($faker->password()),
255+
'password' => Hash::make($faker->password()),
255256
'remember_token' => null,
256257
'roles' => [1, 2],
257258
];
@@ -336,7 +337,7 @@ public function testCreateHasOneRelations()
336337
$inputData = [
337338
'name' => $faker->name,
338339
'email' => $faker->safeEmail,
339-
'password' => bcrypt($faker->password()),
340+
'password' => Hash::make($faker->password()),
340341
'remember_token' => null,
341342
'roles' => [1, 2],
342343
'accountDetails' => [
@@ -398,7 +399,7 @@ public function testMorphToManySelectableRelationship()
398399
$inputData = [
399400
'name' => $faker->name,
400401
'email' => $faker->safeEmail,
401-
'password' => bcrypt($faker->password()),
402+
'password' => Hash::make($faker->password()),
402403
'remember_token' => null,
403404
'bills' => [1],
404405
];
@@ -434,7 +435,7 @@ public function testMorphToManyCreatableRelationship()
434435
$inputData = [
435436
'name' => $faker->name,
436437
'email' => $faker->safeEmail,
437-
'password' => bcrypt($faker->password()),
438+
'password' => Hash::make($faker->password()),
438439
'remember_token' => null,
439440
'recommends' => [
440441
[
@@ -492,7 +493,7 @@ public function testBelongsToManyWithPivotDataRelationship()
492493
$inputData = [
493494
'name' => $faker->name,
494495
'email' => $faker->safeEmail,
495-
'password' => bcrypt($faker->password()),
496+
'password' => Hash::make($faker->password()),
496497
'remember_token' => null,
497498
'superArticles' => [
498499
[
@@ -560,7 +561,7 @@ public function testCreateHasOneWithNestedRelationsRepeatableInterface()
560561
$inputData = [
561562
'name' => $faker->name,
562563
'email' => $faker->safeEmail,
563-
'password' => bcrypt($faker->password()),
564+
'password' => Hash::make($faker->password()),
564565
'remember_token' => null,
565566
'roles' => [1, 2],
566567
'accountDetails' => [
@@ -630,7 +631,7 @@ public function testCreateBelongsToFake()
630631
$inputData = [
631632
'name' => $faker->name,
632633
'email' => $faker->safeEmail,
633-
'password' => bcrypt($faker->password()),
634+
'password' => Hash::make($faker->password()),
634635
'remember_token' => null,
635636
'bang_relation_field' => 1,
636637
];
@@ -689,7 +690,7 @@ public function testCreateHasOneWithNestedRelations()
689690
$inputData = [
690691
'name' => $faker->name,
691692
'email' => $faker->safeEmail,
692-
'password' => bcrypt($faker->password()),
693+
'password' => Hash::make($faker->password()),
693694
'remember_token' => null,
694695
'roles' => [1, 2],
695696
'accountDetails' => [
@@ -734,7 +735,7 @@ public function testCreateHasOneWithNestedRelations()
734735
$inputData = [
735736
'name' => $faker->name,
736737
'email' => $faker->safeEmail,
737-
'password' => bcrypt($faker->password()),
738+
'password' => Hash::make($faker->password()),
738739
'remember_token' => null,
739740
'roles' => [1, 2],
740741
'accountDetails' => [
@@ -778,7 +779,7 @@ public function testMorphOneRelationship()
778779
$inputData = [
779780
'name' => $faker->name,
780781
'email' => $faker->safeEmail,
781-
'password' => bcrypt($faker->password()),
782+
'password' => Hash::make($faker->password()),
782783
'remember_token' => null,
783784
'comment' => [
784785
'text' => 'some test comment text',
@@ -814,7 +815,7 @@ public function testMorphManyCreatableRelationship()
814815
$inputData = [
815816
'name' => $faker->name,
816817
'email' => $faker->safeEmail,
817-
'password' => bcrypt($faker->password()),
818+
'password' => Hash::make($faker->password()),
818819
'remember_token' => null,
819820
'stars' => [
820821
[
@@ -867,7 +868,7 @@ public function testHasManyCreatableRelationship()
867868
$inputData = [
868869
'name' => $faker->name,
869870
'email' => $faker->safeEmail,
870-
'password' => bcrypt($faker->password()),
871+
'password' => Hash::make($faker->password()),
871872
'remember_token' => null,
872873
'universes' => [
873874
[
@@ -952,7 +953,7 @@ public function testHasManySelectableRelationshipWithoutForceDelete()
952953
$inputData = [
953954
'name' => $faker->name,
954955
'email' => $faker->safeEmail,
955-
'password' => bcrypt($faker->password()),
956+
'password' => Hash::make($faker->password()),
956957
'remember_token' => null,
957958
'planets' => [1, 2],
958959
];
@@ -987,7 +988,7 @@ public function testHasManySelectableRelationshipRemoveAllRelations()
987988
$inputData = [
988989
'name' => $faker->name,
989990
'email' => $faker->safeEmail,
990-
'password' => bcrypt($faker->password()),
991+
'password' => Hash::make($faker->password()),
991992
'remember_token' => null,
992993
'planets' => [1, 2],
993994
];
@@ -1052,7 +1053,7 @@ public function testHasManyWithRelationScoped()
10521053
$inputData = [
10531054
'name' => $faker->name,
10541055
'email' => $faker->safeEmail,
1055-
'password' => bcrypt($faker->password()),
1056+
'password' => Hash::make($faker->password()),
10561057
'remember_token' => null,
10571058
'incomes' => [
10581059
[
@@ -1141,7 +1142,7 @@ public function testHasManySelectableRelationshipWithFallbackId()
11411142
$inputData = [
11421143
'name' => $faker->name,
11431144
'email' => $faker->safeEmail,
1144-
'password' => bcrypt($faker->password()),
1145+
'password' => Hash::make($faker->password()),
11451146
'remember_token' => null,
11461147
'planets' => [1, 2],
11471148
];
@@ -1175,7 +1176,7 @@ public function testHasManySelectableRelationshipWithForceDelete()
11751176
$inputData = [
11761177
'name' => $faker->name,
11771178
'email' => $faker->safeEmail,
1178-
'password' => bcrypt($faker->password()),
1179+
'password' => Hash::make($faker->password()),
11791180
'remember_token' => null,
11801181
'planets' => [1, 2],
11811182
];
@@ -1208,7 +1209,7 @@ public function testHasManySelectableRelationshipNonNullableForeignKeyAndDefault
12081209
$inputData = [
12091210
'name' => $faker->name,
12101211
'email' => $faker->safeEmail,
1211-
'password' => bcrypt($faker->password()),
1212+
'password' => Hash::make($faker->password()),
12121213
'remember_token' => null,
12131214
'comets' => [1, 2],
12141215
];
@@ -1242,7 +1243,7 @@ public function testHasManySelectableRelationshipNonNullable()
12421243
$inputData = [
12431244
'name' => $faker->name,
12441245
'email' => $faker->safeEmail,
1245-
'password' => bcrypt($faker->password()),
1246+
'password' => Hash::make($faker->password()),
12461247
'remember_token' => null,
12471248
'planetsNonNullable' => [1, 2],
12481249
];
@@ -1282,7 +1283,7 @@ public function testCreateHasManyRelationWithDelimitedNameSubfields()
12821283
$inputData = [
12831284
'name' => $faker->name,
12841285
'email' => $faker->safeEmail,
1285-
'password' => bcrypt($faker->password()),
1286+
'password' => Hash::make($faker->password()),
12861287
'remember_token' => null,
12871288
'universes' => [
12881289
[
@@ -1335,7 +1336,7 @@ public function testCreateHasOneRelationWithDelimitedNameSubfields()
13351336
$inputData = [
13361337
'name' => $faker->name,
13371338
'email' => $faker->safeEmail,
1338-
'password' => bcrypt($faker->password()),
1339+
'password' => Hash::make($faker->password()),
13391340
'remember_token' => null,
13401341
'roles' => [1, 2],
13411342
'accountDetails' => [
@@ -1383,7 +1384,7 @@ public function testBelongsToManyWithDelimitedNameSubfields()
13831384
$inputData = [
13841385
'name' => $faker->name,
13851386
'email' => $faker->safeEmail,
1386-
'password' => bcrypt($faker->password()),
1387+
'password' => Hash::make($faker->password()),
13871388
'remember_token' => null,
13881389
'superArticles' => [
13891390
[

tests/Unit/CrudPanel/CrudPanelUpdateTest.php

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Faker\Factory;
77
use Illuminate\Database\Eloquent\ModelNotFoundException;
88
use Illuminate\Support\Facades\DB;
9+
use Illuminate\Support\Facades\Hash;
910

1011
/**
1112
* @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Update
@@ -32,27 +33,27 @@ class CrudPanelUpdateTest extends \Backpack\CRUD\Tests\config\CrudPanel\BaseDBCr
3233

3334
private $expectedUpdatedFields = [
3435
'id' => [
35-
'name' => 'id',
36-
'type' => 'hidden',
37-
'label' => 'Id',
36+
'name' => 'id',
37+
'type' => 'hidden',
38+
'label' => 'Id',
3839
'entity' => false,
3940
],
4041
'name' => [
41-
'name' => 'name',
42-
'label' => 'Name',
43-
'type' => 'text',
42+
'name' => 'name',
43+
'label' => 'Name',
44+
'type' => 'text',
4445
'entity' => false,
4546
],
4647
'email' => [
47-
'name' => 'email',
48-
'type' => 'email',
49-
'label' => 'Email',
48+
'name' => 'email',
49+
'type' => 'email',
50+
'label' => 'Email',
5051
'entity' => false,
5152
],
5253
'password' => [
53-
'name' => 'password',
54-
'type' => 'password',
55-
'label' => 'Password',
54+
'name' => 'password',
55+
'type' => 'password',
56+
'label' => 'Password',
5657
'entity' => false,
5758
],
5859
];
@@ -63,9 +64,9 @@ public function testUpdate()
6364
$this->crudPanel->addFields($this->userInputFields);
6465
$faker = Factory::create();
6566
$inputData = [
66-
'name' => $faker->name,
67-
'email' => $faker->safeEmail,
68-
'password' => bcrypt($faker->password()),
67+
'name' => $faker->name,
68+
'email' => $faker->safeEmail,
69+
'password' => Hash::make($faker->password()),
6970
];
7071

7172
$entry = $this->crudPanel->update(1, $inputData);
@@ -82,9 +83,9 @@ public function testUpdateUnknownId()
8283
$this->crudPanel->addFields($this->userInputFields);
8384
$faker = Factory::create();
8485
$inputData = [
85-
'name' => $faker->name,
86-
'email' => $faker->safeEmail,
87-
'password' => bcrypt($faker->password()),
86+
'name' => $faker->name,
87+
'email' => $faker->safeEmail,
88+
'password' => Hash::make($faker->password()),
8889
];
8990

9091
$unknownId = DB::getPdo()->lastInsertId() + 2;
@@ -97,9 +98,9 @@ public function testGetUpdateFields()
9798
$this->crudPanel->addFields($this->userInputFields);
9899
$faker = Factory::create();
99100
$inputData = [
100-
'name' => $faker->name,
101-
'email' => $faker->safeEmail,
102-
'password' => bcrypt($faker->password()),
101+
'name' => $faker->name,
102+
'email' => $faker->safeEmail,
103+
'password' => Hash::make($faker->password()),
103104
];
104105
$entry = $this->crudPanel->create($inputData);
105106
$this->addValuesToExpectedFields($entry->id, $inputData);
@@ -131,10 +132,10 @@ public function testGetUpdateFieldsWithEnum()
131132
], [
132133
'name' => 'tags',
133134
], [
134-
'label' => 'Author',
135-
'type' => 'select',
136-
'name' => 'user_id',
137-
'entity' => 'user',
135+
'label' => 'Author',
136+
'type' => 'select',
137+
'name' => 'user_id',
138+
'entity' => 'user',
138139
'attribute' => 'name',
139140
], [
140141
'name' => 'status',
@@ -148,16 +149,16 @@ public function testGetUpdateFieldsWithEnum()
148149
]);
149150
$faker = Factory::create();
150151
$inputData = [
151-
'content' => $faker->text(),
152-
'tags' => $faker->words(3, true),
153-
'user_id' => 1,
154-
'metas' => null,
155-
'extras' => null,
156-
'status' => 'publish',
157-
'state' => 'COLD',
158-
'style' => 'DRAFT',
159-
'cast_metas' => null,
160-
'cast_tags' => null,
152+
'content' => $faker->text(),
153+
'tags' => $faker->words(3, true),
154+
'user_id' => 1,
155+
'metas' => null,
156+
'extras' => null,
157+
'status' => 'publish',
158+
'state' => 'COLD',
159+
'style' => 'DRAFT',
160+
'cast_metas' => null,
161+
'cast_tags' => null,
161162
'cast_extras' => null,
162163
];
163164
$article = $this->crudPanel->create($inputData);

0 commit comments

Comments
 (0)