This repository has been archived by the owner on Jan 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove deprecated middleware * Add password to Paste entity * Add new custom rule to determine password match * Improve paste menu * Add new FormRequest for update paste * Add fixed Paste test on PasteTableSeeder * Add the ability to edit a paste * Improve tests suite * Remove dead code * Add new alert style for callouts * Add the ability to set a password on paste creation and fork * Fix a bug that caused crashes when a password was null * Fix a stupid bug on LanguageFactory causing tests to fail
- Loading branch information
Showing
29 changed files
with
613 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Wdi\Http\Handlers\Paste; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\View\View; | ||
use Wdi\Http\Handlers\Handler; | ||
|
||
/** | ||
* Class EditPasteHandler | ||
* @package Wdi\Http\Handlers\Paste | ||
*/ | ||
final class EditPasteHandler extends Handler | ||
{ | ||
/** | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\View\View | ||
*/ | ||
public function __invoke(Request $request) : View | ||
{ | ||
return view("paste.edit")->with("paste", $request->paste); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Wdi\Http\Handlers\Paste; | ||
|
||
use Illuminate\Http\RedirectResponse; | ||
use Wdi\Http\Handlers\Handler; | ||
use Wdi\Http\Requests\UpdatePasteRequest; | ||
|
||
/** | ||
* Class UpdatePasteHandler | ||
* @package Wdi\Http\Handlers\Paste | ||
*/ | ||
final class UpdatePasteHandler extends Handler | ||
{ | ||
/** | ||
* @param \Wdi\Http\Requests\UpdatePasteRequest $request | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function __invoke(UpdatePasteRequest $request) : RedirectResponse | ||
{ | ||
$paste = $request->paste; | ||
$paste->update($request->only(["name", "description", "language_id", "extension", "code"])); | ||
|
||
return redirect()->route("paste.show", $paste); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Wdi\Http\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Validation\Rule; | ||
use Wdi\Entities\Language; | ||
use Wdi\Rules\PasswordMatch; | ||
|
||
/** | ||
* Class UpdatePasteRequest | ||
* @package Wdi\Http\Requests | ||
*/ | ||
final class UpdatePasteRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() : bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() : array | ||
{ | ||
return [ | ||
"name" => [ | ||
"required", | ||
"min:3", | ||
], | ||
"code" => [ | ||
"required", | ||
], | ||
"password" => [ | ||
"required", | ||
new PasswordMatch($this->paste->password), | ||
], | ||
"language_id" => [ | ||
"required", | ||
Rule::exists(Language::TABLE_NAME, "id"), | ||
], | ||
"extension" => [ | ||
"required", | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Wdi\Rules; | ||
|
||
use Hash; | ||
use Illuminate\Contracts\Validation\Rule; | ||
|
||
/** | ||
* Class PasswordMatch | ||
* @package Wdi\Rules | ||
*/ | ||
final class PasswordMatch implements Rule | ||
{ | ||
/** @var string */ | ||
private $password; | ||
|
||
/** | ||
* Create a new rule instance. | ||
* @param string $password | ||
*/ | ||
public function __construct(string $password) | ||
{ | ||
$this->password = $password; | ||
} | ||
|
||
/** | ||
* Determine if the validation rule passes. | ||
* | ||
* @param string $attribute | ||
* @param mixed $value | ||
* @return bool | ||
*/ | ||
public function passes($attribute, $value) | ||
{ | ||
return Hash::check($value, $this->password); | ||
} | ||
|
||
/** | ||
* Get the validation error message. | ||
* | ||
* @return string | ||
*/ | ||
public function message() | ||
{ | ||
return "La password non corrisponde."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
database/migrations/2017_11_07_065216_add_password_column_to_pastes_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
/** | ||
* Class AddPasswordColumnToPastesTable | ||
*/ | ||
final class AddPasswordColumnToPastesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table("pastes", function (Blueprint $table) { | ||
$table->string("password")->nullable()->after("description"); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table("pastes", function (Blueprint $table) { | ||
$table->dropColumn("password"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.