1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-25 03:43:33 +01:00

User photo in invite

This commit is contained in:
FreeScout 2018-09-17 00:02:36 -07:00
parent 8d9b28c7aa
commit 1710fdf5bb
2 changed files with 40 additions and 5 deletions

View File

@ -27,6 +27,9 @@ class PublicController extends Controller
*/
public function userSetup($hash)
{
if (auth()->user()) {
return redirect()->route('dashboard');
}
$user = User::where('invite_hash', $hash)->first();
return view('public/user_setup', ['user' => $user]);
@ -38,6 +41,9 @@ class PublicController extends Controller
*/
public function userSetupSave($hash, Request $request)
{
if (auth()->user()) {
return redirect()->route('dashboard');
}
$user = User::where('invite_hash', $hash)->first();
if (!$user) {
@ -51,7 +57,24 @@ class PublicController extends Controller
'phone' => 'max:60',
'timezone' => 'required|string|max:255',
'time_format' => 'required',
'photo_url' => 'nullable|image|mimes:jpeg,png,jpg,gif',
]);
$validator->setAttributeNames([
'photo_url' => __('Photo'),
]);
// Photo
$validator->after(function ($validator) use ($user, $request) {
if ($request->hasFile('photo_url')) {
$path_url = $user->savePhoto($request->file('photo_url'));
if ($path_url) {
$user->photo_url = $path_url;
} else {
$validator->errors()->add('photo_url', __('Error occured processing the image. Make sure that PHP GD extension is enabled.'));
}
}
});
if ($validator->fails()) {
return redirect()->route('user_setup', ['hash' => $hash])
@ -59,7 +82,11 @@ class PublicController extends Controller
->withInput();
}
$user->fill($request->all());
$request_data = $request->all();
if (isset($request_data['photo_url'])) {
unset($request_data['photo_url']);
}
$user->fill($request_data);
$user->password = bcrypt($request->password);

View File

@ -28,7 +28,7 @@
{{ __("Let's setup your profile.") }}
</p>
</div>
<form class="form-horizontal margin-top" method="POST" action="">
<form class="form-horizontal margin-top" method="POST" action="" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
@ -110,11 +110,19 @@
</div>
<div class="form-group{{ $errors->has('photo_url') ? ' has-error' : '' }}">
<label for="photo_url" class="col-sm-4 control-label">{{ __('Photo') }} (todo)</label>
<label for="photo_url" class="col-sm-4 control-label">{{ __('Photo') }}</label>
<div class="col-sm-7">
<input type="file" name="photo" id="photo" disabled="disabled">
<p class="block-help">{{ __('Only visible in :app_name.', ['app_name' => \Config::get('app.name')]) }} {{ __('Image will be re-sized to 200x200. JPG, GIF, PNG accepted.') }}</p>
<div class="controls">
@if ($user->photo_url)
<div id="user-profile-photo">
<img src="{{ $user->getPhotoUrl() }}" alt="{{ __('Profile Image') }}" width="50" height="50"><br/>
<a href="#" id="user-photo-delete" data-loading-text="{{ __('Deleting') }}…">{{ __('Delete Photo') }}</a>
</div>
@endif
<input type="file" name="photo_url">
<p class="block-help">{{ __('Only visible in :app_name.', ['app_name' => \Config::get('app.name')]) }} {{ __('Image will be re-sized to 200x200. JPG, GIF, PNG accepted.') }}</p>
</div>
@include('partials/field_error', ['field'=>'photo_url'])
</div>
</div>