update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
106
dev/app-bak/Http/Controllers/UserUpdatePasswordController.php
Executable file
106
dev/app-bak/Http/Controllers/UserUpdatePasswordController.php
Executable file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Validator;
|
||||
use Request;
|
||||
|
||||
|
||||
class UserUpdatePasswordController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function updatePassword()
|
||||
{
|
||||
return view('user.update_password');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function updatePasswordStore()
|
||||
{
|
||||
$rules = array(
|
||||
'old_password' => 'required|old_password:' . Auth::user()->password,
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
);
|
||||
|
||||
Validator::extend('old_password', function ($attribute, $value, $parameters, $validator) {
|
||||
|
||||
return Hash::check($value, current($parameters));
|
||||
|
||||
});
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.update_password')->withErrors($validator);
|
||||
|
||||
}
|
||||
$user = Auth::user();
|
||||
$data = Request::all();
|
||||
$user->fill([
|
||||
'password' => Hash::make($data['password'])
|
||||
])->save();
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('user_update_password'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function updatePasswordFirst(){
|
||||
if(!Auth::user()->isPasswort()){
|
||||
return view('user.update_password_first');
|
||||
}
|
||||
return redirect(route('user_update_password'));
|
||||
}
|
||||
|
||||
|
||||
public function updatePasswordFirstStore()
|
||||
{
|
||||
$rules = array(
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
);
|
||||
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.update_password_first')->withErrors($validator);
|
||||
|
||||
}
|
||||
$user = Auth::user();
|
||||
$data = Request::all();
|
||||
$user->fill([
|
||||
'password' => Hash::make($data['password'])
|
||||
])->save();
|
||||
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect('/home');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue