fixed the config forms not working (controler needed update)

pull/26/head
Ondřej Hruška 6 years ago
parent 2e075799f2
commit a71fed254a
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 17
      app/Exceptions/Handler.php
  2. 37
      app/Http/Controllers/ProfileController.php
  3. 6
      app/View/WidgetFactory.php
  4. 6
      resources/views/layouts/nav-buttons.blade.php
  5. 6
      resources/views/profile/edit-account.blade.php
  6. 6
      resources/views/profile/edit-profile.blade.php
  7. 9
      routes/web.php

@ -5,6 +5,7 @@ namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Validation\ValidationException;
class Handler extends ExceptionHandler
{
@ -63,4 +64,20 @@ class Handler extends ExceptionHandler
? response()->json(['message' => $exception->getMessage()], 401)
: redirect()->guest(route('login'));
}
/**
* Convert a validation exception into a response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Validation\ValidationException $exception
* @return \Illuminate\Http\Response
*/
protected function invalid($request, ValidationException $exception)
{
flash()->error("Some form fields were not filled correctly.");
return redirect($exception->redirectTo ?? url()->previous())
->withInput($request->except($this->dontFlash))
->withErrors($exception->errors(), $exception->errorBag);
}
}

@ -27,20 +27,41 @@ class ProfileController extends Controller
}
/**
* Edit own profile
* Edit own profile (this does not include auth settings etc)
*
* @param User $user
* @return \Illuminate\View\View
*/
public function edit()
public function editProfile()
{
return view('profile.edit')->with('user', \user());
return view('profile.edit-profile')->with('user', \user());
}
public function editAccount()
{
return view('profile.edit-account', ['user' => user()]);
}
/**
* Store changed profile
*/
public function store(Request $request)
public function storeProfile(Request $request)
{
$input = $this->validate($request, [
'bio' => ['nullable', VALI_TEXT],
'title' => ['required', VALI_LINE],
'website' => ['required', VALI_LINE],
]);
$user = user();
$user->fill($input->all());
$user->save();
flash()->success('Settings saved');
return back();
}
public function storeAccount(Request $request)
{
$input = $this->validate($request, [
'name' => [
@ -53,9 +74,6 @@ class ProfileController extends Controller
VALI_EMAIL,
Rule::unique('users')->ignoreModel(\user()),
],
'bio' => ['nullable', VALI_TEXT],
'title' => ['required', VALI_LINE],
'website' => ['required', VALI_LINE],
'new_password' => ['nullable', 'confirmed', VALI_PASSWORD],
]);
@ -90,11 +108,6 @@ class ProfileController extends Controller
return back();
}
public function manageOauth()
{
return view('profile.logins', ['user' => user()]);
}
public function forgetSocialLogin($id)
{
$identity = user()->socialIdentities()->where('id', $id)->first();

@ -21,11 +21,13 @@ class WidgetFactory
"</div>";
}
public function par($text, $extraClasses='')
public function par($text, $extraClasses='', $escape=true)
{
return
"<div class=\"row\">".
"<p class=\"col-md-$this->fieldCols offset-md-$this->labelCols mb-2 ".e($extraClasses)."\">".e($text)."</o>".
"<p class=\"col-md-$this->fieldCols offset-md-$this->labelCols mb-2 ".e($extraClasses)."\">".
($escape ? e($text) : $text) .
"</p>".
"</div>";
}

@ -8,13 +8,13 @@ $aclass = $dropdown ? 'dropdown-item' : 'nav-link';
{!! $li !!}
<a class="{{ $aclass }}" href="{{ route('profile.edit') }}">
<i class="fa-sliders fa-pr"></i>{{ __('Settings') }}
<i class="fa-sliders fa-pr"></i>{{ __('Profile') }}
</a>
{!! $endli !!}
{!! $li !!}
<a class="{{ $aclass }}" href="{{ route('profile.manage-oauth') }}">
<i class="fa-key-modern fa-pr"></i>{{ __('Security') }}
<a class="{{ $aclass }}" href="{{ route('account.edit') }}">
<i class="fa-key-modern fa-pr"></i>{{ __('Account') }}
</a>
{!! $endli !!}

@ -5,12 +5,12 @@
@section('content')
@php(Widget::setLayout(3, 7))
<form method="POST" action="{{route('profile.store')}}" class="row justify-content-center">
<form method="POST" action="{{route('account.store')}}" class="row justify-content-center">
@csrf
<div class="col-md-10">
{!! Widget::header(1, 'Login Settings') !!}
{!! Widget::par('Confirm using the save button at the bottom.') !!}
{!! Widget::header(1, 'Your Account') !!}
{!! Widget::par('Confirm using the save button at the bottom.', 'text-muted') !!}
</div>
<div class="col-md-10 mt-3">

@ -10,7 +10,11 @@
<div class="col-md-10">
@php(Widget::setLayout(3, 7))
{!! Widget::header(1, 'Settings') !!}
{!! Widget::header(1, 'Your Profile') !!}
{!! Widget::par('
Username can be changed on the
<a href="'.e(route('account.edit')).'">account settings</a> page.
', 'text-muted', false) !!}
{!! Widget::text('title', 'Display Name')->value($user->title)->required()->autofocus()
->help('Shown on your profile page, tables, comments, etc.') !!}

@ -30,10 +30,13 @@ Route::group(['middleware' => 'auth'], function () {
Route::group([
'prefix' => 'profile',
], function () {
Route::get('edit', 'ProfileController@edit')->name('profile.edit');
Route::post('edit', 'ProfileController@store')->name('profile.store');
Route::get('edit', 'ProfileController@editProfile')->name('profile.edit');
Route::post('edit', 'ProfileController@storeProfile')->name('profile.store');
Route::post('create', 'TableController@storeNew')->name('table.storeNew');
Route::get('logins', 'ProfileController@manageOauth')->name('profile.manage-oauth');
Route::get('logins', 'ProfileController@editAccount')->name('account.edit');
Route::post('logins', 'ProfileController@storeAccount')->name('account.store');
});
});

Loading…
Cancel
Save