重置密码成功了,但是setLoginStatus不能设置cookie就直接跳到登录页面了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public function actionResetPwd() { if ( \Yii:: $app ->request->isGet ){ $user_info = $this ->current_user; return $this ->render( 'reset_pwd' ,[ 'user_info' => $user_info ]); } $old_password = trim( $this ->post( 'old_password' ) ); $new_password = trim( $this ->post( 'new_password' ) ); if ( mb_strlen( $old_password , 'utf-8' ) < 1 ){ return $this ->renderJson([], '请输入原密码!!' ,-1); } if ( mb_strlen( $new_password , 'utf-8' ) < 6 ){ return $this ->renderJson([], '新密码长度不能小于6位!!' ,-1); } if ( $old_password == $new_password ){ return $this ->renderJson([], '新密码不能等于旧密码!!' ,-1); } $user_info = $this ->current_user; if ( ! $user_info ->verifyPassword( $old_password ) ){ return $this ->renderJson([], "原密码输入错误!!" ,-1); } $user_info ->setPassword( $new_password ); $user_info ->updated_time = date ( "Y-m-d H:i:s" ,time() ); $user_info ->update( 0 ); $this ->setLoginStatus( $user_info ); return $this ->renderJson([], '修改密码成功!!' ,200); } |