2017-01-06 21 views
1

私はGrails 3.2.4を使用しています。ユーザ名のメールプロパティをユーザ名として使用しようとしています。Grails - Spring Security UIユーザー名のメール

これまでのところ、私は春のセキュリティコアは、以下の構成設定を使用して、ユーザー名として電子メールを使用して取得するために管理してきました:

grails.plugin.springsecurity.userLookup.usernamePropertyName='email' 

ただし、登録機能は、このことを考慮していないようです電子メールとパスワードのみを使用して新しいユーザーを登録させることはありません。

私はRegisterControllerをオーバーライドしようといくつかの試みを行いましたが、ヌルユーザー名に関するさまざまなエラーが引き続き発生します。

私は非常に単純なものを見逃しているようです。どんな助けや指示も大変ありがとうございます。

+0

チェック制約 - DBはすでに以前に作成した場合と、ヌル値がfalseで、その後にtrueに変更された場合、テーブル変更カラムをNULL値に変更するには、手動db upateが必要です。あなたは実際のコードやエラーメッセージなしで監視をしています - 誰かが何か役に立つことをするための痕跡や何かをあなたに役立ててください – Vahid

+0

ありがとう@vahid、私は春のセキュリティで登録機能を作る方法を尋ねていたので、 -uiは電子メールをユーザー名として使用します。 –

答えて

1

バージョンspring-security-ui-3.0.0.M2の場合、usernameプロパティは無効にできない可能性があります。

String paramNameToPropertyName(String paramName, String controllerName) { 
    // Properties in the ACL classes and RegistrationCode aren't currently 
    // configurable, and the PersistentLogin class is generated but its 
    // properties also aren't configurable. Since this method is only by 
    // the controllers to be able to hard-code param names and lookup the 
    // actual domain class property name we can short-circuit the logic here. 
    // Additionally there's no need to support nested properties (e.g. 
    // 'aclClass.className' for AclObjectIdentity search) since those are 
    // not used in GSP for classes with configurable properties. 

    if (!paramName) { 
     return paramName 
    } 

    Class<?> clazz = domainClassesByControllerName[controllerName] 
    String name 
    if (clazz) { 
     String key = paramName 
     if (paramName.endsWith('.id')) { 
      key = paramName[0..-4] 
     } 
     name = classMappings[clazz][key] 
    } 
    name ?: paramName 
} 

PS私は今、私のユーザーのドメインクラスでこのような何かを行うことによってこの問題を回避取得しています。username属性のユーザードメインクラスの

static transients = ["migrating"]] 
String username = null 

public void setEmail(String email) { 
    this.email = email 
    this.username = email 
} 
+0

ありがとう!正確に私が探していた情報 –

関連する問題