springsource-security-coreプラグインの周りにユーザーコントローラーを実装しています。
コントローラ(「ユーザー」)でユーザーインスタンスを「表示」するとき、パスワードパラメータがヌルになり、空白の編集コントロールとして表示されることを確認したいと思います。
これは「show」メソッドのコードです。
@Secured(['ROLE_SUPERUSER','ROLE_USER'])
def show(Long id) {
/**
* If we're not the Superuser, then we only want to see the instance of the logged in user.
*/
def userInstance
if (SpringSecurityUtils.ifNotGranted('ROLE_SUPERUSER')) {
userInstance=springSecurityService.currentUser
} else {
userInstance = User.get(id)
}
if (!userInstance) {
flash.message = message(code: 'default.not.found.message', args: [message(code: 'user.label', default: 'User'), id])
redirect(action: "list")
return
}
userInstance.setPassword(null)
[userInstance: userInstance]
}
'userInstance'に"watch"を設定すると、userInstance.setPassword(null)が目的の効果を発揮し、"password"パラメーターを'null'に設定します。
ただし、同じパラメータセットを使用してビューをレンダリングすると、パスワードが入力されます。
「パスワード確認」フィールドも実装したいと思っています。私はgroovy/grailに少し慣れていないので、このステップバイステップで自分の道を感じています。「userInstance」を渡すことで、「User」ドメインクラスのインスタンスを渡すようです。
ドメインクラスに2つのエンコードされたフィールドが必要ですか、それともその場でGSPにフィールドを追加し、エンコードされたパスワードでドメインクラスを保存する前に、コントローラーでこれを検証できますか?