2012-07-24 322 views
3

我已經在我的Grails應用程序中安裝了Spring Security插件,看到登錄工作正常,但是當我想爲用戶創建註冊並在註冊後對用戶進行身份驗證時,請在代碼中手動,我不能。Grails Spring Security註冊/註冊用戶

有沒有解決方案? Spring Security如何不允許簡單地使用認證用戶推送會話或Spring安全上下文。 這裏是我的嘗試:

UsernamePasswordAuthenticationToken uat = new UsernamePasswordAuthenticationToken(user.email, user.password, null); 
uat.setDetails(user); 
SecurityContext context = SecurityContextHolder.getContext(); 
context.setAuthentication(uat); 

這對用戶進行認證,但我不能與下面的代碼得到他:

springSecurityService.currentUser 
這個

只有:

SecurityContextHolder.getContext().getAuthentication().getPrincipal(); 

我我現在很困惑,什麼是使用Spring Security的正確方法。

我開始建立我自己的UserDetailsS​​ervice,但我很困惑,不知道如果我想創建自己的認證方法,接下來的步驟是什麼?

回答