小编ma-*_*ick的帖子

使用symfony2通过URL自动登录

我正在尝试使用symfony2和一种特殊的网址进行自动登录.就像这里描述的那样.

但是当我使用symfony2调试工具栏时,我注意到它说:"未经过身份验证".但我有一个会话,我有一个用户对象,这一切似乎工作得很好.为什么调试工具栏会这样说?

并且zadbuchy描述的方法有问题吗?我正在使用symfony 2.1.6.

编辑:我知道这可能不是"最安全"的登录方式(感谢@Bart的讨论),但我很好奇为什么symfony2无法正确识别登录.

我的代码看起来像这样:

$firewall = "support_secured_area";
$token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
$this->get('security.context')->setToken($token);
$session = $this->get('session');
$session->set('_security_'.$firewall, serialize($token));

// Fire the login event (Suggestion from the answer, but unfortunately it doesn't work :( ).
$event = new InteractiveLoginEvent($this->getRequest(), $token);
$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);
Run Code Online (Sandbox Code Playgroud)

php autologin symfony symfony-2.1

5
推荐指数
1
解决办法
6094
查看次数

如何使用 JPA 和 CriteriaBuilder 按结果计算组?

我认为这几乎是不可能的或非常棘手的。我正在使用 CriteriaBuilder、JPA 2.0、Hibernate 和 MariaDB,并希望使用 CriteriaBuilder 构建以下查询:

SELECT COUNT(*) FROM
   (SELECT DISTINCT(SomeColumn) // I think this is not possible?
    FROM MyTable
    WHERE ... COMPLEX CLAUSE ...
    GROUP BY SomeColumn) MyTable
Run Code Online (Sandbox Code Playgroud)

我的问题:可能吗?如果,如何?

感谢您对这件事的关注!

标记

jpa-2.0

4
推荐指数
1
解决办法
2万
查看次数

烤宽面条/ Theano错误的尺寸数量

用改良的mnist.py(Lasagne的主要例子)加入Lasagne和Theano,训练一个非常简单的XOR.

import numpy as np

import theano
import theano.tensor as T

import time

import lasagne

X_train = [[[[0, 0], [0, 1], [1, 0], [1, 1]]]] # (1)
y_train = [[[[1, 0], [0, 1], [0, 1], [1, 0]]]]

# [0,      1,      1,      0]

X_train = np.array(X_train).astype(np.uint8)
y_train = np.array(y_train).astype(np.uint8)


print X_train.shape

X_val = X_train
y_val = y_train

X_test = X_train
y_test = y_train


def build_mlp(input_var=None):
    # This creates an MLP of two hidden layers of 800 units each, followed by
    # …
Run Code Online (Sandbox Code Playgroud)

python theano lasagne

2
推荐指数
1
解决办法
2520
查看次数

标签 统计

autologin ×1

jpa-2.0 ×1

lasagne ×1

php ×1

python ×1

symfony ×1

symfony-2.1 ×1

theano ×1