2013-05-18 24 views
6

我使用的是SecureSocial 2.0.7,我實現了一個UserServicePlugin,用戶可以登錄。我可以停止並重新啓動服務器(或者重新編譯),並且用戶將保持登錄狀態。升級到SecureSocial 2.0.12,現在會話沒有被持久

自升級到2.0.12以來,登錄會話在服務器重新啓動時不會持久。

我在UserServicePlugin的每個方法中都添加了調試日誌記錄。用戶登錄時正在登錄saved。但是,當服務器重新啓動,我試圖訪問一個頁面是以前登錄的用戶,我只看到在日誌中:

[info] play - database [default] connected at jdbc:postgresql://localhost/xxxxxx 
[info] application - [securesocial] loaded templates plugin: sec.SecureSocialViews 
[info] play - Starting application default Akka system. 
[info] application - [securesocial] loaded user service: class sec.LoginUserService 
[info] application - [securesocial] loaded password hasher bcrypt 
[info] application - [securesocial] loaded identity provider: userpass 
[info] play - Application started (Dev) 
[debug] application - [securesocial] calling deleteExpiredTokens() 
[debug] application - deleteExpiredTokens 
[debug] application - [securesocial] anonymous user trying to access : '/supplier/requests' 

任何想法?我想知道是否由於某種原因,登錄cookie正在獲取nuked之前,甚至檢查現有的登錄會話......

我使用用戶名/密碼認證。

+0

難道這與SecureSocial將事物存儲在Play Cache中有什麼關係嗎? (我只是使用默認的內存播放緩存。) – andrewf

+2

我在Play 2.1和Master分支Securesocial上也發現了這一點。我有一個數據庫支持的用戶服務,並配置了ehcache以堅持到磁盤。但是,在重新啓動服務器時,所有用戶都會註銷。令人沮喪。 –

回答

4

用戶信息存儲在會話中的方式發生了變化。該模塊現在不使用Play會話cookie,而是使用單獨的一個。這個cookie有一個認證者ID。用戶信息現在存儲在服務器端的AuthenticatorStore實現中。默認實現使用Play緩存,這就是爲什麼您需要在重新編譯時再次進行身份驗證的原因。緩存中的數據正在清除。

如果您想保留用戶登錄的重新編譯/重啓後,您可以:

  1. 創建AuthenticatorStore的實現,仍然存在的東西。
  2. 更改ehcache.xml文件以保留在文件系統中(diskPersistent =「true」)。
+0

我更新了我的ehcache.xml文件,但這不起作用 –

+0

您是否將ehcache.xml文件複製到您的app/conf目錄? – Jorge

+0

是的,我做了,該文件是在應用程序/ conf –