Laravel 5.3 - 未根据请求设置会话存储

时间:2016-10-31 05:50:30

标签: laravel session laravel-5.3

我的Laravel应用中添加了电子邮件验证系统。我用过" jrean""为它包装。

现在我要覆盖getVerification()特征中的VerifiesUsers函数。为此,我在RegisterController中添加了一个具有相同名称的函数。

public function getVerification(Request $request, $token)

{    

 $this->validateRequest($request);

 try {
    UserVerification::process($request->input('email'), $token, $this->userTable());
 } catch (UserNotFoundException $e) {
    return redirect($this->redirectIfVerificationFails());
 } catch (UserIsVerifiedException $e) {
    return redirect($this->redirectIfVerified());
 } catch (TokenMismatchException $e) {
    return redirect($this->redirectIfVerificationFails());
 }

 $request->session()->flash('message', 'Email address has been successfully verified');
 return redirect($this->redirectAfterVerification());
}

但是当我的函数按照验证调用被调用时,我收到错误"会话存储未按请求设置。"错误。我不确定它究竟意味着什么以及如何解决它。

1 个答案:

答案 0 :(得分:3)

发生这种情况的原因是因为包中声明的路由没有放在web中间件中。

要解决此问题,您可以将该套餐中的路线添加到routes/web.php。路线是:

Route::get('email-verification/error', 'Auth\RegisterController@getVerificationError')->name('email-verification.error');
Route::get('email-verification/check/{token}', 'Auth\RegisterController@getVerification')->name('email-verification.check');

您需要确保config/app.php Jrean\UserVerification\UserVerificationServiceProvider::class,App位于Illuminate服务提供商之上(但位于import UIKit import RxSwift import RxCocoa class InputViewController: UIInputViewController { private var separatorView: UIView? private var answerTextView: ConstrainedTextView? private var closeButton: UIButton? private var tipLabel: UILabel? // private var generalHeightConstraint: NSLayoutConstraint? private var separatorHeightConstraint: NSLayoutConstraint? private var answerTextViewBottomConstraint: NSLayoutConstraint? private let junk = DisposeBag() override func viewDidLoad() { super.viewDidLoad() configureView() } private func configureView() { // view.autoresizingMask = .flexibleHeight view.backgroundColor = UIColor.white view.frame = CGRect(x: 0, y: 0, width: view.superview?.bounds.width ?? 100, height: 70) // view.translatesAutoresizingMaskIntoConstraints = false // generalHeightConstraint = AutoLayoutSetAttribute(view, .height, 70) // Separator separatorView = UIView() separatorView?.backgroundColor = UIColor.gray separatorView?.translatesAutoresizingMaskIntoConstraints = false view.addSubview(separatorView!) AutoLayoutEqualizeSuper(separatorView, .left, 0) AutoLayoutEqualizeSuper(separatorView, .right, 0) AutoLayoutEqualizeSuper(separatorView, .top, 0) separatorHeightConstraint = AutoLayoutSetAttribute(separatorView, .height, 1) // Close Button closeButton = UIButton(type: .system) closeButton?.setTitle("Hide", for: .normal) closeButton?.titleLabel?.font = UIFont.systemFont(ofSize: 17) closeButton?.translatesAutoresizingMaskIntoConstraints = false closeButton?.addTarget(self, action: #selector(dismissKeyboard), for: .touchUpInside) view.addSubview(closeButton!) AutoLayoutSetAttribute(closeButton, .width, 70) AutoLayoutEqualizeSuper(closeButton, .right, -5) view.addConstraint(NSLayoutConstraint(item: closeButton!, attribute: .top, relatedBy: .equal, toItem: separatorView, attribute: .bottom, multiplier: 1, constant: 0)) // Tip Label tipLabel = UILabel() tipLabel?.textColor = UIColor.darkGray tipLabel?.text = "Input answer:" tipLabel?.font = UIFont.systemFont(ofSize: 17) tipLabel?.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tipLabel!) AutoLayoutEqualizeSuper(tipLabel, .left, 5) AutoLayoutEqualize(tipLabel, separatorView, .top, 0) view.addConstraint(NSLayoutConstraint(item: tipLabel!, attribute: .right, relatedBy: .equal, toItem: closeButton, attribute: .left, multiplier: 1, constant: 0)) // Text View answerTextView = ConstrainedTextView() answerTextView?.backgroundColor = UIColor.white answerTextView?.delegate = self answerTextView?.scrollsToTop = false answerTextView?.showsVerticalScrollIndicator = false answerTextView?.font = REG_FONT(15) answerTextView?.maxLines = 5 answerTextView?.translatesAutoresizingMaskIntoConstraints = false answerTextView?.layer.masksToBounds = true answerTextView?.layer.cornerRadius = 7 answerTextView?.layer.borderColor = UIColor.lightGray.withAlphaComponent(0.7).cgColor answerTextView?.layer.borderWidth = 1 view.addSubview(answerTextView!) AutoLayoutEqualizeSuper(answerTextView, .left, 5) AutoLayoutEqualizeSuper(answerTextView, .right, -5) answerTextViewBottomConstraint = AutoLayoutEqualizeSuper(answerTextView, .bottom, -5) view.addConstraint(NSLayoutConstraint(item: answerTextView!, attribute: .top, relatedBy: .equal, toItem: tipLabel, attribute: .bottom, multiplier: 1, constant: 0)) view.addConstraint(NSLayoutConstraint(item: answerTextView!, attribute: .top, relatedBy: .equal, toItem: closeButton, attribute: .bottom, multiplier: 1, constant: 0)) answerTextView? .rx .observe(CGRect.self, "bounds") .distinctUntilChanged { $0?.size.height == $1?.size.height } .subscribe { [unowned self] newBounds in if var newHeight = newBounds.element??.size.height, let separatorHeight = self.separatorHeightConstraint?.constant, let buttonHeight = self.closeButton?.intrinsicContentSize.height, let bottomSpace = self.answerTextViewBottomConstraint?.constant { newHeight = newHeight == 0 ? 30 : newHeight let generalHeight = newHeight + separatorHeight + buttonHeight + abs(bottomSpace) self.view.frame = CGRect(x: 0, y: 0, width: self.view.superview?.bounds.width ?? 100, height: generalHeight) // self.generalHeightConstraint?.constant = generalHeight // UIView.animate(withDuration: 0.2) { // self.view.setNeedsLayout() // self.view.layoutIfNeeded() // } } } .addDisposableTo(junk) } } // MARK: - UITextViewDelegate Protocol Conformance extension InputViewController: UITextViewDelegate { func textViewShouldBeginEditing(_ textView: UITextView) -> Bool { textView.inputAccessoryView = view return true } func textViewShouldEndEditing(_ textView: UITextView) -> Bool { textView.inputAccessoryView = nil return true } } 服务提供商下方)。

希望这有帮助!