用户在grails中创建后无法登录

时间:2018-04-17 14:11:13

标签: java grails groovy

我正在创建一个来自createorg表单的用户,它也保存在数据库中,但当我尝试从该用户名和密码登录时,它说错误,无法找到这样的用户名和密码。但是我保存的用户从bootstrap可以轻松登录。

createorg.gsp

chrome://inspect/

organizationcontroller.groovy

  <g:form action="saveorg" method="POST">
                    <h3>Enter Username</h3>
                    <g:textField name="username" placeholder="Enter UserName"/><br>
                    <h3>Enter Password</h3>
                    <g:textField name="password" id="pass1" placeholder="Enter Password" /><br>
                     <h3>Confirm Password</h3>
                     <g:textField name="password" id="pass2" placeholder="Confirm Password" onkeyup='check();'/><br>

                 <div class="alert alert-success" style="display: none" id="showAlert">
                    <strong><span id='message'></span></strong>
                </div>
                <div class="alert alert-success" style="display: none" id="showAlert1">
                    <strong><span id='message1'></span></strong>
                </div>

                 <g:submitButton  class="btn btn-primary" name="saveorg" value="saveorg" id="submit" />

            </g:form>

1 个答案:

答案 0 :(得分:1)

@Transactional
def save(User user) {
    if (user == null) {
        transactionStatus.setRollbackOnly()
        render status: NOT_FOUND
        return
    }

    if (user.hasErrors()) {
        transactionStatus.setRollbackOnly()
        render(template: "/errors/errors", model: [errors: user.errors])
        return
    }

    user.save flush:true

    respond user, [status: CREATED, view:"show"]
}