Update Profile, fix unauthenticated private profiles

This commit is contained in:
Daniel Supernault 2021-07-07 00:40:01 -06:00
parent 1a2e41b1e3
commit 9017f7c4e1
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
4 changed files with 115 additions and 123 deletions

View file

@ -47,7 +47,8 @@ class ProfileController extends Controller
}); });
if ($user->is_private == true) { if ($user->is_private == true) {
abort(404); $profile = null;
return view('profile.private', compact('user'));
} }
$owner = false; $owner = false;

View file

@ -703,6 +703,11 @@
this.fetchProfile(); this.fetchProfile();
let u = new URLSearchParams(window.location.search); let u = new URLSearchParams(window.location.search);
let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true'; let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true';
if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') {
this.layout = 'moment';
}
if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') { if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') {
this.layout = 'metro'; this.layout = 'metro';
} }
@ -739,10 +744,6 @@
} }
}); });
} }
if(window.outerWidth < 576) {
$('nav.navbar').hide();
this.isMobile = true;
}
}, },
updated() { updated() {

View file

@ -1,107 +1,97 @@
<div class="bg-white py-5 border-bottom"> <div class="bg-white py-5 border-bottom">
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-12 col-md-4 d-flex"> <div class="col-12 col-md-4 d-flex">
<div class="profile-avatar mx-auto"> <div class="profile-avatar mx-auto">
<img class="rounded-circle box-shadow" src="{{$user->avatarUrl()}}" width="172px" height="172px"> <img class="rounded-circle box-shadow" src="{{$user->avatarUrl()}}" width="172px" height="172px">
</div> </div>
</div> </div>
<div class="col-12 col-md-8 d-flex align-items-center"> <div class="col-12 col-md-8 d-flex align-items-center">
<div class="profile-details"> <div class="profile-details">
<div class="username-bar pb-2 d-flex align-items-center"> <div class="username-bar pb-2 d-flex align-items-center">
<span class="font-weight-ultralight h3">{{$user->username}}</span> <span class="font-weight-ultralight h3">{{$user->username}}</span>
@if(Auth::check() && $is_following == true) @if(Auth::check() && $is_following == true)
<span class="pl-4"> <span class="pl-4">
<form class="follow-form" method="post" action="/i/follow" style="display: inline;" data-id="{{$user->id}}" data-action="unfollow"> <form class="follow-form" method="post" action="/i/follow" style="display: inline;" data-id="{{$user->id}}" data-action="unfollow">
@csrf @csrf
<input type="hidden" name="item" value="{{$user->id}}"> <input type="hidden" name="item" value="{{$user->id}}">
<button class="btn btn-outline-secondary font-weight-bold px-4 py-0" type="submit">Unfollow</button> <button class="btn btn-outline-secondary font-weight-bold px-4 py-0" type="submit">Unfollow</button>
</form> </form>
</span> </span>
@elseif(Auth::check() && $requested == true) @elseif(Auth::check() && $requested == true)
<span class="pl-4"> <span class="pl-4">
<button class="btn btn-outline-secondary font-weight-bold px-4 py-0 disabled" disabled type="button">Follow Requested</button> <button class="btn btn-outline-secondary font-weight-bold px-4 py-0 disabled" disabled type="button">Follow Requested</button>
</span> </span>
@elseif(Auth::check() && $is_following == false) @elseif(Auth::check() && $is_following == false)
<span class="pl-4"> <span class="pl-4">
<form class="follow-form" method="post" action="/i/follow" style="display: inline;" data-id="{{$user->id}}" data-action="follow"> <form class="follow-form" method="post" action="/i/follow" style="display: inline;" data-id="{{$user->id}}" data-action="follow">
@csrf @csrf
<input type="hidden" name="item" value="{{$user->id}}"> <input type="hidden" name="item" value="{{$user->id}}">
<button class="btn btn-primary font-weight-bold px-4 py-0" type="submit">Follow</button> <button class="btn btn-primary font-weight-bold px-4 py-0" type="submit">Follow</button>
</form> </form>
</span> </span>
@endif @endif
<span class="pl-4"> @auth
<i class="fas fa-cog fa-lg text-muted cursor-pointer" data-toggle="modal" data-target="#ctxProfileMenu"></i> <span class="pl-4">
<div class="modal" tabindex="-1" role="dialog" id="ctxProfileMenu"> <i class="fas fa-cog fa-lg text-muted cursor-pointer" data-toggle="modal" data-target="#ctxProfileMenu"></i>
<div class="modal-dialog modal-dialog-centered modal-sm"> <div class="modal" tabindex="-1" role="dialog" id="ctxProfileMenu">
<div class="modal-content"> <div class="modal-dialog modal-dialog-centered modal-sm">
<div class="modal-body p-0"> <div class="modal-content">
<div class="list-group-item cursor-pointer text-center rounded text-dark" onclick="window.App.util.clipboard('{{$user->url()}}');$('#ctxProfileMenu').modal('hide')"> <div class="modal-body p-0">
Copy Link <div class="list-group-item cursor-pointer text-center rounded text-dark" onclick="window.App.util.clipboard('{{$user->url()}}');$('#ctxProfileMenu').modal('hide')">
</div> Copy Link
@auth </div>
<div class="list-group-item cursor-pointer text-center rounded text-dark" onclick="muteProfile()"> @auth
Mute <div class="list-group-item cursor-pointer text-center rounded text-dark" onclick="muteProfile()">
</div> Mute
<a class="list-group-item cursor-pointer text-center rounded text-dark text-decoration-none" href="i/report?type=user&id={{$user->id}}"> </div>
Report User <a class="list-group-item cursor-pointer text-center rounded text-dark text-decoration-none" href="i/report?type=user&id={{$user->id}}">
</a> Report User
<div class="list-group-item cursor-pointer text-center rounded text-dark" onclick="blockProfile()"> </a>
Block <div class="list-group-item cursor-pointer text-center rounded text-dark" onclick="blockProfile()">
</div> Block
@endauth </div>
<div class="list-group-item cursor-pointer text-center rounded text-muted" onclick="$('#ctxProfileMenu').modal('hide')"> @endauth
Close <div class="list-group-item cursor-pointer text-center rounded text-muted" onclick="$('#ctxProfileMenu').modal('hide')">
</div> Close
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</span> </div>
</div> </span>
<div class="profile-stats pb-3 d-inline-flex lead"> @endauth
<div class="font-weight-light pr-5"> </div>
<span class="font-weight-bold">{{$user->statuses()->whereNull('reblog_of_id')->whereNull('in_reply_to_id')->count()}}</span> </div>
Posts </div>
</div> </div>
</div> </div>
<p class="lead mb-0">
<span class="font-weight-bold">{{$user->name}}</span>
@if($user->remote_url)
<span class="badge badge-info">REMOTE PROFILE</span>
@endif
</p>
<p class="mb-0 lead">{{$user->bio}}</p>
<p class="mb-0"><a href="{{$user->website}}" class="font-weight-bold" rel="me external nofollow noopener" target="_blank">{{str_limit($user->website, 30)}}</a></p>
</div>
</div>
</div>
</div>
</div> </div>
@push('scripts') @push('scripts')
@auth
<script type="text/javascript"> <script type="text/javascript">
function muteProfile() { function muteProfile() {
axios.post('/i/mute', { axios.post('/i/mute', {
type: 'user', type: 'user',
item: '{{$user->id}}' item: '{{$user->id}}'
}).then(res => { }).then(res => {
$('#ctxProfileMenu').modal('hide'); $('#ctxProfileMenu').modal('hide');
$('#ctxProfileMenu').hide(); $('#ctxProfileMenu').hide();
swal('Muted Profile', 'You have successfully muted this profile.', 'success'); swal('Muted Profile', 'You have successfully muted this profile.', 'success');
}); });
} }
function blockProfile() { function blockProfile() {
axios.post('/i/block', { axios.post('/i/block', {
type: 'user', type: 'user',
item: '{{$user->id}}' item: '{{$user->id}}'
}).then(res => { }).then(res => {
$('#ctxProfileMenu').modal('hide'); $('#ctxProfileMenu').modal('hide');
$('#ctxProfileMenu').hide(); $('#ctxProfileMenu').hide();
swal('Blocked Profile', 'You have successfully blocked this profile.', 'success'); swal('Blocked Profile', 'You have successfully blocked this profile.', 'success');
}); });
} }
</script> </script>
@endpush @endauth
@endpush

View file

@ -2,28 +2,28 @@
@section('content') @section('content')
@if (session('error')) @if (session('error'))
<div class="alert alert-danger text-center font-weight-bold mb-0"> <div class="alert alert-danger text-center font-weight-bold mb-0">
{{ session('error') }} {{ session('error') }}
</div> </div>
@endif @endif
@include('profile.partial.private-info') @include('profile.partial.private-info')
<div class="container"> <div class="container">
<div class="profile-timeline mt-2 mt-md-4"> <div class="profile-timeline mt-2 mt-md-4">
<div class="card"> <div class="">
<div class="card-body py-5"> <div class="py-5">
<p class="text-center lead font-weight-bold mb-0"> <p class="text-center lead font-weight-bold">
{{__('profile.privateProfileWarning')}} {{__('profile.privateProfileWarning')}}
</p> </p>
@if(!Auth::check()) @if(!Auth::check())
<p class="text-center mb-0">{{ __('profile.alreadyFollow', ['username'=>$user->username])}}</p> <p class="text-center mb-0">{{ __('profile.alreadyFollow', ['username'=>$user->username])}}</p>
<p class="text-center mb-0"><a href="{{route('login')}}">{{__('Log in')}}</a></p> <p class="text-center mb-0"><a href="{{route('login')}}">{{__('Log in')}}</a></p>
<p class="text-center mb-0">{{__('profile.loginToSeeProfile')}}</p> <p class="text-center mb-0">{{__('profile.loginToSeeProfile')}}</p>
@endif @endif
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@endsection @endsection
@ -34,4 +34,4 @@
@if($user->remote_url) @if($user->remote_url)
<meta name="robots" content="noindex, nofollow"> <meta name="robots" content="noindex, nofollow">
@endif @endif
@endpush @endpush