Skip to content

Commit 63c7157

Browse files
committed
New visibility option: "internal"
Share pastes only with CAS authenticated users.
1 parent d35fd42 commit 63c7157

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

app/Http/Controllers/EditPasteController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function edit($link, Requests\EditPaste $request){
5151
$privacy = Input::get('privacy');
5252

5353
// Ici on vérifie que l'user a pas foutu le bronx dans les dropdown list
54-
$possibleValuesPrivacy = array("link", "password", "private");
54+
$possibleValuesPrivacy = array("link", "internal", "password", "private");
5555
if (in_array($privacy, $possibleValuesPrivacy) == false) return view('paste/edit');
5656

5757
// Si l'user a choisi password-protected, on hash son pass, sinon on met 'disabled' dans la variable

app/Http/Controllers/PasteController.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function submit(Requests\StorePaste $request){
3939
$privacy = Input::get('privacy');
4040

4141
// Ici on vérifie que l'user a pas foutu le bronx dans les dropdown list
42-
$possibleValuesPrivacy = array("link", "password", "private");
42+
$possibleValuesPrivacy = array("link", "internal", "password", "private");
4343
if (in_array($privacy, $possibleValuesPrivacy) == false) return view('paste/index');
4444

4545
// Si l'user a choisi password-protected, on hash son pass, sinon on met 'disabled' dans la variable
@@ -138,6 +138,13 @@ public function view($link, Request $request){
138138
if($isSameUser) $privacy = "Private";
139139
else abort('404');
140140
}
141+
elseif ($paste->privacy == "internal"){
142+
if (cas()->isAuthenticated()) {
143+
$privacy = "Internal access";
144+
} else {
145+
return abort('404');
146+
}
147+
}
141148
elseif ($paste->privacy == "password"){
142149
$privacy = "Password-protected";
143150
if ($request->isMethod('post')) {

resources/views/paste/dashboard.blade.php

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
{{-- Bloc d'infos --}}
4949
<td class="hidden-xs">
5050
@if ($userPaste->privacy == "link") <i class="fa fa-globe fa-lg" data-toggle="tooltip" data-placement="bottom" title="Public"></i>
51+
@elseif ($userPaste->privacy == "internal") <i class="fa fa-users fa-lg" data-toggle="tooltip" data-placement="bottom" title="Internal"></i>
5152
@elseif ($userPaste->privacy == "password") <i class="fa fa-key fa-lg" data-toggle="tooltip" data-placement="bottom" title="Password-protected"></i>
5253
@elseif ($userPaste->privacy == "private") <i class="fa fa-user-secret fa-lg" data-toggle="tooltip" data-placement="bottom" title="Private"></i> @endif
5354
</td>

resources/views/paste/edit.blade.php

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ function checkvalue(value)
8686
<label for="privacy">Privacy</label>
8787
<select class="form-control" name="privacy" id="privacy" onchange='checkvalue(this.value)'>
8888
<option value="link" {{ $privacy == "link" ? 'selected' : '' }}>Unlisted, access with link</option>
89+
<option value="internal" {{ $privacy == "internal" ? 'selected' : '' }}>Internal</option>
8990
<option value="password" {{ $privacy == "password" || $errors->has('pastePassword') ? 'selected' : '' }}>Password-protected</option>
9091
<option value="private" {{ $privacy == "private" ? 'selected' : '' }}>Private, only me</option>
9192
</select>

resources/views/paste/index.blade.php

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function checkvalue(value)
7979
<label for="privacy">Privacy</label>
8080
<select class="form-control" name="privacy" id="privacy" onchange='checkvalue(this.value)'>
8181
<option value="link">Unlisted, access with link</option>
82+
<option value="internal">Internal</option>
8283
<option value="password" @if ($errors->has('pastePassword')) selected="selected" @endif>Password-protected</option>
8384
@if (cas()->isAuthenticated())
8485
<option value="private">Private, only me</option>

0 commit comments

Comments
 (0)