Skip to content

Commit c53ea3a

Browse files
committed
fix operations
1 parent b79b1f1 commit c53ea3a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

app/Http/Controllers/MainController.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function newNoteSubmit(Request $request)
6868
public function editNote($id)
6969
{
7070
$id = Operations::decryptId($id);
71+
72+
if($id === null){
73+
return redirect()->route('home');
74+
}
7175
//echo "I'm editing note with id = {$id}";
7276

7377
// load note
@@ -105,6 +109,10 @@ public function editNoteSubmit(Request $request)
105109
// decrypt note_id
106110
$id = Operations::decryptId($request->note_id);
107111

112+
if($id === null){
113+
return redirect()->route('home');
114+
}
115+
108116
// load note
109117
$note = Note::find($id);
110118

@@ -120,6 +128,10 @@ public function editNoteSubmit(Request $request)
120128
public function deleteNote($id)
121129
{
122130
$id = Operations::decryptId($id);
131+
132+
if($id === null){
133+
return redirect()->route('home');
134+
}
123135
// echo "I'm deleting note with id = {$id}";
124136

125137
// load note
@@ -133,6 +145,10 @@ public function deleteNoteConfirm($id)
133145
{
134146
$id = Operations::decryptId($id);
135147

148+
if($id === null){
149+
return redirect()->route('home');
150+
}
151+
136152
// load note
137153
$note = Note::find($id);
138154

app/Services/Operations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static function decryptId($value)
1313
try {
1414
$value = Crypt::decrypt($value);
1515
} catch (DecryptException $e) {
16-
return redirect()->route('home');
16+
return null;
1717
}
1818

1919
return $value;

0 commit comments

Comments
 (0)