【问题标题】:Add more properties in spring security UI grails plugin在 spring security UI grails 插件中添加更多属性
【发布时间】:2021-06-26 00:56:02
【问题描述】:

我正在使用Grails 4.0.9spring security core grails plugin 4.0.3spring-security-ui:4.0.0.M1,我想在用户注册时添加一些属性,例如telephone number and age,我如何在使用默认Spring security default UI 时做到这一点

【问题讨论】:

    标签: spring grails spring-security


    【解决方案1】:

    插件为您生成默认实现。因此,您需要更新 RegisterController 和表单的默认生成模板。

    请查看插件文档中的customisation section

    【讨论】:

    • 我按照文档中的说明添加,它创建了一个空的注册控制器!所以我从插件中找到的原始操作复制了所有操作,还复制了RegisterContoller内的RegisterCommand,但是在按下create your account后我得到了这个错误No signature of method: grails.plugin.springsecurity.ui.strategy.DefaultRegistrationCodeStrategy.createUser() is applicable for argument types: (c.s.RegisterCommand) values: [c.s.RegisterCommand@3eabeea3] Possible solutions: createUser(grails.plugin.springsecurity.ui.RegisterCommand)
    • 能否分享一个示例应用程序?
    • ,发现共享代码有什么问题吗?
    • 是的,您看到上述错误是因为您使用不同的 RegisterCommand 类调用 uiRegistrationCodeStrategy.createUser(registerCommand)。您需要将此实现更新为自定义。
    • 根据您的要求,您想要的是重用 UI,而其他一切都需要自定义或扩展现有类。因此,您可能需要使用新 bean 覆盖 SpringSecurityUiService bean 定义,该新 bean 将添加 createUser(MyRegisterCommand)
    猜你喜欢
    • 2016-01-13
    • 2016-05-24
    • 2013-07-29
    • 1970-01-01
    • 2015-03-27
    • 2011-08-15
    • 2016-03-23
    • 2012-09-29
    • 2014-01-05
    相关资源
    最近更新 更多