我正在尝试以编程方式在Drupal 8中登录用户。这是我的代码。
if(isset($uid)) {
$user = User::load($uid);
user_login_finalize($user);
$user_destination = \Drupal::destination()->get();
$response = new RedirectResponse($user_destination);
$response->send();
exit(0);
}
我在监视器中收到消息'Session for ...但是用户没有登录。有人能告诉我我的代码有什么问题吗?
答案 0 :(得分:1)
在控制器中使用exit()不是一个好主意。 Drupal在执行控制器后会产生更多动作,但exit()会在脚本执行之前停止它们。为避免这种情况,您必须从控制器返回RedirectResponce():
cell.photoImageView.sd_setImage(with: url, placeholderImage: nil, options: .allowInvalidSSLCertificates, progress: nil
, completed: { (image, error, cacheType, url) in