9
我使用的是來自播放框架的「安全」模塊,其工作原理非常好。我可以通過在我的應用程序中發佈/登錄路徑來登錄用戶。如何使用播放框架安全模塊在用戶創建後登錄用戶
但是,當我「創建/註冊」一個新用戶時,我希望該用戶在用戶創建後自動登錄。這樣,我似乎無法通過編程工作,即無需發佈表單登錄。
我爲我的用戶創建的動作電流代碼如下:
public static void create(@Required @Email String email, @Required String password, @Required @Equals("password") String passwordConfirmation) {
User user = new User(email);
user.password = new Crypto().encryptAES(password);
user.save();
try {
Secure.authenticate(email, password, false); // <== this is the action in secure module mapped to /login
} catch(Throwable t) {
t.printStackTrace();
}
}
所以我手動調用Secure.authentication(username, password, remember)
方法,但是這只是我重定向到登錄頁面,而不是我的目標網頁。
我有一種感覺,因爲我直接調用Secure.authenticate而不是通過請求/響應來設置cookie或其他東西,但我只是不確定。
任何想法?
這確實是缺失的一塊 - 謝謝! – Damien