php - Laravel change password right after email confirmation view not working -


when user created random password (and auth code) created , send email user.

when clicked on link in email user status 1 (so active) , user able change password right away.

now doesn't work want to.

usercontroller:

public function store(createuserrequest $request, user $user, attribute $attribute) // unnecessary code  if ((input::get('usertype_id')) > 1) {     $randompassword = str_random(8);     $user->password = hash::make($randompassword);      $authentication_code = str_random(12);     $user->authentication_code = $authentication_code;      $user->active = 0; };  $user->save();  if ((input::get('usertype_id')) > 1) {     // email sturen met verficatie code     $email = input::get('email');      mail::send('emails.user', ['user' => $user, 'password' => $randompassword, 'authentication_code' => $authentication_code], function ($message) use ($email) {         $message->to($email, 'lilopel')->subject('lilopel: verify account!');     }); };   public function confirmuser($authentication_code) {     if (!$authentication_code)     {         return 'auth code not found!';     }      $user = user::where('authentication_code', '=', $authentication_code)->first();      if (!$user)     {         return 'user not found!';     }      $user->active = 1;     $user->save();      session::put('user_id', $user->id);      return view('user.setpassword', ['user' => $user]);     //return redirect()->route('user.setpassword', [$user_id]); }   public function setpassword(setpasswordrequest $request) {     $user_id = session::get('user_id');       $user = $this->user->find($user_id);      $user->fill($request->only('password'));      $user->save(); } 

route:

route::get('user/verify/{authenticationcode}', 'usercontroller@confirmuser');  route::get('user/password', 'usercontroller@setpassword'); 

view:

{!! form::model($user, ["route"=>['user.setpassword', $user->id] , "method" => 'patch']) !!}      <div class="form-group {{ $errors->has('password') ? 'has-error' : '' }}">         {!! form::label('password', trans('common.password'), ['class' => 'form-label col-sm-3 control-label         text-capitalize']) !!}         <div class="col-sm-6">             {!! form::password('password', ['name' => 'password', "class"=>"form-control","placeholder" =>             trans('common.password') ]) !!}             {!! $errors->first('password', '<span class="help-block">:message</span>') !!}         </div>     </div>     <div class="form-group {{ $errors->has('confirm_password') ? 'has-error' : '' }}">         {!! form::label('password_confirmation', trans('common.confirmpassword'), ['class' => 'form-label         col-sm-3 control-label text-capitalize']) !!}         <div class="col-sm-6">             {!! form::password('password_confirmation', ['name' => 'password_confirmation',             "class"=>"form-control","placeholder" => trans('common.confirmpassword') ]) !!}             {!! $errors->first('password_confirmation', '<span class="help-block">:message</span>') !!}         </div>     </div>  {!! form::submit( trans('common.edit'), ["class"=>"btn btn-primary text-capitalize center-block   "]) !!}  {!! form::close() !!} 

email links works, status of user gets active, .blade give route [user.setpassword] not defined. (view: public_html/server2/resources/views/user/setpassword.blade.php) error.

work togetherto use route do, need named route.

change this

route::get('user/password', 'usercontroller@setpassword'); 

to this

route::get('user/password', [     'as' => 'user.setpassword',     'uses' => 'usercontroller@showprofile' ]); 

also, make sure http verbs of route , form's method work together.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -