lundi 19 septembre 2016

change password user laravel 5.3

I want to create form with 3 field (old_password, new_password, confirm_password) with laravel 5.

View

old password : {!! Form::password('old_password',['class' => 'form-control']) !!}

New Password : {!! Form::password('password',['class' => 'form-control']) !!}

Confirm New Password : {!! Form::password('verify_password',['class' => 'form-control']) !!}

Controller when user register

public function postRegister(Request $request)
{
    $rules = [
        'email'             =>  'required|email|unique:users',
        'confirm_email'     =>  'required|same:email',
        'password'          =>  'required|min:8|http://regex:/^(?=\S*[a-z])(?=\S*[!@#$&*])(?=\S*[A-Z])(?=\S*[\d])\S*$/',
        'verify_password'   =>  'required|same:password',
    ];

    $messages = [
        'email.required'            => 'email tidak boleh kosong',
        'password.required'         => 'password tidak boleh kosong',
        'password.min'              => 'Password harus minimal 8 karakter',
        'password.regex'            => 'Format password harus terdiri dari kombinasi huruf besar, angka dan karakter spesial (contoh:!@#$%^&*?><).',
        'verify_password.required'  => 'Verify Password tidak boleh kosong',
        'email.email'               => 'Format Email tidak valid',
        'email.unique'              => 'Email yang anda masukkan telah digunakan',
        'verify_password.same'      => 'Password tidak sama!',
    ];

    $this->validate($request,$rules,$messages);


    $newUser = $this->user->create([
        'email'         =>  $request->email,
        'password'      =>  \Hash::make($request->password),
    ]);
    $this->activationService->sendActivationMail($newUser);

    return redirect('/account/login')->with('success', 'Check your email');
}

I'm new in laravel, i've read some similar problem to change password in stackoverflow but it didn't help me.

How should I write code in my controller for change password user?. Thanks in Advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire