English 中文(简体)
Grails Acegi:更新用户名称
原标题:Grails Acegi: update username

我用Acegi(AKA Spring Security) p在我的Grails上。 In SecurityConfig.groovy 我增加了一条线。

userName =  email 

因此,电子邮件领域被用作用户名称。 我发现,如果我改变电子邮件的现场并挽救目标,例如:

user.email =  my_new_email@foo.com 
user.save(failOnError: true)  

储蓄没有错误,但电子邮件领域实际上没有更新。 我的猜测是,Acegi plugin禁止改变用户名称领域,但如果有人能够证实,我不胜感激。

Thanks, Don

问题回答

acegi使用的土地标注。 作为一个非常巧合的问题,我本周有同样的问题, ,昨天转播了解决办法!

简言之,你有两个选择:

通过增加藏匿点来改变对域标的贴切 用户=伪造 SecurityConfig.groovy

以在安全区取代域标

private def refreshUserPrincipal(user) {
    GrantedAuthority[] auths = user.authorities.collect {
        new GrantedAuthorityImpl(it.authority)
    }
    def grailsUser = new GrailsUserImpl(
        user.username
            "",
            true,
            true,
            true,
            true,
            auths,
            user);
    def authToken = new UsernamePasswordAuthenticationToken(grailsUser, "", auths)
    SecurityContextHolder.context.authentication = authToken
}

(Check the source of :GrailsUserImpl,看所有这些真实价值是什么!)

你们只能做:

String oldUsername = user.username
user.username= my@newusername.com 
user.save()
if(oldUsername != user.username) {
  SpringSecurityUtils.reauthenticate(user.username, null)
}




相关问题
grails + gwt request handling via controllers

I am new to gwt. I am trying to integrate gwt+grails.Can anybody provide me a good example for handling the request using grails controllers and not a custom servlet.I will be really thankful if ...

Error loading the grails gwt module xml

I ve installed the plugin from this article by Peter http://www.cacoethes.co.uk/blog/groovyandgrails/the-command-pattern-w.... While compile time its not able to find the module file which is present ...

Sorting Objects Based on Custom Domain Class Methods

I have a domain class, in which I ve defined some methods which give the object a score based on different algorithms (eg. popularity). I now want to retrieve a list of these objects sorted by one of ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

Hibernate/GORM: collection was not processed by flush()

I have an integration test in my Grails application that fails when I try to save an entity of type Member invitingMember.save(flush: true) This raises the following exception org.hibernate....

热门标签