ユーザの本人判定をModelに逃した
This commit is contained in:
		
							
								
								
									
										13
									
								
								app/User.php
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								app/User.php
									
									
									
									
									
								
							| @@ -4,6 +4,7 @@ namespace App; | ||||
|  | ||||
| use Illuminate\Notifications\Notifiable; | ||||
| use Illuminate\Foundation\Auth\User as Authenticatable; | ||||
| use Illuminate\Support\Facades\Auth; | ||||
|  | ||||
| class User extends Authenticatable | ||||
| { | ||||
| @@ -35,8 +36,18 @@ class User extends Authenticatable | ||||
|      * @param int $size 画像サイズ | ||||
|      * @return string Gravatar 画像URL | ||||
|      */ | ||||
|     public function getProfileImageUrl($size = 30) : string { | ||||
|     public function getProfileImageUrl($size = 30) : string | ||||
|     { | ||||
|         $hash = md5(strtolower(trim($this->email))); | ||||
|         return '//www.gravatar.com/avatar/' . $hash . '?s=' . $size; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * このユーザがログイン中のユーザ本人であるかをチェックします。 | ||||
|      * @return bool 本人かどうか | ||||
|      */ | ||||
|     public function isMe() | ||||
|     { | ||||
|         return Auth::check() && $this->id === Auth::user()->id; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -8,13 +8,13 @@ | ||||
|             @endcomponent | ||||
|         </div> | ||||
|         <div class="col-lg-8"> | ||||
|             @if ($user->is_protected && !(Auth::check() && $user->id === Auth::user()->id)) | ||||
|             @if ($user->is_protected && !$user->isMe()) | ||||
|                 <div class="card"> | ||||
|                     <div class="card-body"> | ||||
|                         <span class="oi oi-lock-locked"></span> このユーザはチェックイン履歴を公開していません。 | ||||
|                     </div> | ||||
|                 </div> | ||||
|             @elseif ($ejaculation->is_private && !(Auth::check() && $user->id === Auth::user()->id)) | ||||
|             @elseif ($ejaculation->is_private && !$user->isMe()) | ||||
|                 <div class="card"> | ||||
|                     <div class="card-body"> | ||||
|                         <span class="oi oi-lock-locked"></span> 非公開チェックインのため、表示できません | ||||
| @@ -26,7 +26,7 @@ | ||||
|                         <!-- span --> | ||||
|                         <div class="d-flex justify-content-between"> | ||||
|                             <h5>{{ $ejaculatedSpan ?? '精通' }} <small class="text-muted">{{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ~ ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}</small></h5> | ||||
|                             @if (Auth::check() && $user->id === Auth::user()->id) | ||||
|                             @if ($user->isMe()) | ||||
|                                 <div> | ||||
|                                     <a class="text-secondary timeline-action-item" href="#"><span class="oi oi-pencil" data-toggle="tooltip" data-placement="bottom" title="修正"></span></a> | ||||
|                                     <a class="text-secondary timeline-action-item" href="#" data-toggle="modal" data-target="#deleteCheckinModal" data-id="{{ $ejaculation->id }}" data-date="{{ $ejaculation->ejaculated_date }}"><span class="oi oi-trash" data-toggle="tooltip" data-placement="bottom" title="削除"></span></a> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| @extends('user.base') | ||||
|  | ||||
| @section('tab-content') | ||||
| @if ($user->is_protected && !(Auth::check() && $user->id === Auth::user()->id)) | ||||
| @if ($user->is_protected && !$user->isMe()) | ||||
|     <p class="mt-4"> | ||||
|         <span class="oi oi-lock-locked"></span> このユーザはチェックイン履歴を公開していません。 | ||||
|     </p> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| @extends('user.base') | ||||
|  | ||||
| @section('tab-content') | ||||
| @if ($user->is_protected && !(Auth::check() && $user->id === Auth::user()->id)) | ||||
| @if ($user->is_protected && !$user->isMe()) | ||||
|     <p class="mt-4"> | ||||
|         <span class="oi oi-lock-locked"></span> このユーザはチェックイン履歴を公開していません。 | ||||
|     </p> | ||||
| @@ -12,7 +12,7 @@ | ||||
|                 <!-- span --> | ||||
|                 <div class="d-flex justify-content-between"> | ||||
|                     <h5>{{ $ejaculation->ejaculated_span ?? '精通' }} <a href="{{ route('checkin.show', ['id' => $ejaculation->id]) }}" class="text-muted"><small>{{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ~ ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}</small></a></h5> | ||||
|                     @if (Auth::check() && $user->id === Auth::user()->id) | ||||
|                     @if ($user->isMe()) | ||||
|                     <div> | ||||
|                         <a class="text-secondary timeline-action-item" href="#"><span class="oi oi-pencil" data-toggle="tooltip" data-placement="bottom" title="修正"></span></a> | ||||
|                         <a class="text-secondary timeline-action-item" href="#" data-toggle="modal" data-target="#deleteCheckinModal" data-id="{{ $ejaculation->id }}" data-date="{{ $ejaculation->ejaculated_date }}"><span class="oi oi-trash" data-toggle="tooltip" data-placement="bottom" title="削除"></span></a> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| @extends('user.base') | ||||
|  | ||||
| @section('tab-content') | ||||
| @if ($user->is_protected && !(Auth::check() && $user->id === Auth::user()->id)) | ||||
| @if ($user->is_protected && !$user->isMe()) | ||||
|     <p class="mt-4"> | ||||
|         <span class="oi oi-lock-locked"></span> このユーザはチェックイン履歴を公開していません。 | ||||
|     </p> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 shibafu
					shibafu