【问题标题】:Encryption method for cuba platform古巴平台的加密方法
【发布时间】:2023-03-25 10:30:01
【问题描述】:

古巴有自己的后端系统来添加用户。 现在我需要在前端编写一个用户注册。 我使用的古巴版本是 6.9 我知道这个版本的加密是SHA1:https://doc.cuba-platform.com/manual-6.9/login.html 现在我的问题是:我不知道如何给数据库设置加密密码。

我通过元数据创建一个实体

User user = metadata.create(User.class);
user.setPassword(passWord);

【问题讨论】:

    标签: java polymer cuba-platform


    【解决方案1】:

    我不确定这是最好的选择,但我使用了以下代码:

    @Inject
    protected PasswordEncryption passwordEncryption;
    
    ...
    
    user.setPassword(passwordEncryption.getPasswordHash(user.getId(), password));
    

    【讨论】:

    【解决方案2】:

    我认为您只需要使用以下代码创建 html 文件:

    <div class="span6">
        <h3>Login</h3>
    
        <div th:if="${(param.error != null)}">
            <p>Invalid username / password</p>
        </div>
    
        <form id="f" name="f" method="POST" action="login">
            <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
            <div>
                <div>
                    <label style="width: 80px" for="login">Login</label>
                    <input type="text" id="login" name="login" value=""/>
                </div>
                <div>
                    <label style="width: 80px" for="password">Password</label>
                    <input type="password" id="password" name="password" value=""/>
                </div>
            </div>
            <button type="submit">Login</button>
        </form>
    </div>
    

    然后从控制器请求它:

    @RequestMapping(value = "/", method = RequestMethod.GET)
        public String index(Model model) {
            if (PortalSessionProvider.getUserSession().isAuthenticated()) {
                LoadContext l = new LoadContext(User.class);
                l.setQueryString("select u from sec$User u");
                model.addAttribute("users", dataService.loadList(l));
            }
            return "index";
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多