title: How to edit user (even password) with SpringSecurity Core and UI in grails
body: <p>my goal is to create an edit page where the user can change his data.</p>
  
  <p>this is my _form:</p>
  
  <pre><code>&lt;div class="fieldcontain ${hasErrors(bean: user, field: 'firstName', 'error')} required"&gt;
  &lt;label for="firstName"&gt;
  &lt;g:message code="userSec.firstName.label" default="First Name" /&gt;
  &lt;span class="required-indicator"&gt;*&lt;/span&gt;
  &lt;/label&gt;
  &lt;g:textField name="firstName" required="" value="${user?.firstName}"/&gt;
  &lt;/div&gt;
  
  &lt;div class="fieldcontain ${hasErrors(bean: user, field: 'lastName', 'error')} required"&gt;
  &lt;label for="lastName"&gt;
  &lt;g:message code="userSec.lastName.label" default="Last Name" /&gt;
  &lt;span class="required-indicator"&gt;*&lt;/span&gt;
  &lt;/label&gt;
  &lt;g:textField name="lastName" required="" value="${user?.lastName}"/&gt;
  &lt;/div&gt;
  
  &lt;div class="fieldcontain ${hasErrors(bean: user, field: 'username', 'error')} required"&gt;
  &lt;label for="username"&gt;
  &lt;g:message code="userSec.username.label" default="Username" /&gt;
  &lt;span class="required-indicator"&gt;*&lt;/span&gt;
  &lt;/label&gt;
  &lt;g:textField name="username" required="" value="${user?.username}"/&gt;
  &lt;/div&gt;
  
  &lt;div class="fieldcontain ${hasErrors(bean: user, field: 'email', 'error')} required"&gt;
  &lt;label for="email"&gt;
  &lt;g:message code="userSec.email.label" default="Email" /&gt;
  &lt;span class="required-indicator"&gt;*&lt;/span&gt;
  &lt;/label&gt;
  &lt;g:field type="email" name="email" required="" value="${user?.email}"/&gt;
  &lt;/div&gt;
  
  &lt;div class="fieldcontain ${hasErrors(bean: command, field: 'password', 'error')} required"&gt;
  &lt;label for="password"&gt; 
  &lt;g:message code="user.password.label" default="Password" /&gt;
  &lt;span class="required-indicator"&gt;*&lt;/span&gt;
  &lt;/label&gt;
  &lt;g:field type="password" name="password" class="passwd" required="" value="${command.password}" /&gt;
  &lt;span id="result"&gt;&lt;/span&gt;
  &lt;/div&gt;
  &lt;div class="fieldcontain ${hasErrors(bean: command, field: 'password2', 'error')} required"&gt;
  &lt;label for="password2"&gt; 
  &lt;g:message code="user.password2.label" default="Password (again)" /&gt;
  &lt;span class="required-indicator"&gt;*&lt;/span&gt;
  &lt;/label&gt;
  &lt;g:field type="password" name="password2" required="" value="${command.password2}" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and this is my edit page:</p>
  
  <pre><code>&lt;%@ page import="p2s.UserSec" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta name="layout" content="main"&gt;
  &lt;g:set var="entityName" value="${message(code: 'userSec.label', default: 'UserSec')}" /&gt;
  &lt;title&gt;&lt;g:message code="default.edit.label" args="[entityName]" /&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;a href="#edit-userSec" class="skip" tabindex="-1"&gt;&lt;g:message code="default.link.skip.label" default="Skip to content&amp;hellip;"/&gt;&lt;/a&gt;
  &lt;div class="nav" role="navigation"&gt;
  &lt;ul&gt;
  &lt;li&gt;&lt;a class="home" href="${createLink(uri: '/')}"&gt;&lt;g:message code="default.home.label"/&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div id="edit-userSec" class="content scaffold-edit" role="main"&gt;
  &lt;h1&gt;&lt;g:message code="default.edit.label" args="[entityName]" /&gt;&lt;/h1&gt;
  &lt;g:if test="${flash.message}"&gt;
  &lt;div class="message" role="status"&gt;${flash.message}&lt;/div&gt;
  &lt;/g:if&gt;
  &lt;g:hasErrors bean="${user}"&gt;
  &lt;ul class="errors" role="alert"&gt;
  &lt;g:eachError bean="${user}" var="error"&gt;
  &lt;li &lt;g:if test="${error in org.springframework.validation.FieldError}"&gt;data-field-id="${error.field}"&lt;/g:if&gt;&gt;&lt;g:message error="${error}"/&gt;&lt;/li&gt;
  &lt;/g:eachError&gt;
  &lt;/ul&gt;
  &lt;/g:hasErrors&gt;
  &lt;g:form url="[resource:user, action:'update']" method="PUT" &gt;
  &lt;g:hiddenField name="version" value="${user?.version}" /&gt;
  &lt;fieldset class="form"&gt;
  &lt;g:render template="form"/&gt;
  &lt;/fieldset&gt;
  &lt;fieldset class="buttons"&gt;
  &lt;g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /&gt;
  &lt;/fieldset&gt;
  &lt;/g:form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How can I let the user modify his data? I've got many trouble with the password because i can't decode it and match it with the password that the user give me when he want to change it.</p>
  
  <p>I'd like to use Spring method to do this.</p>
  
  <p>Thanks to all, sorry if this is a easy question but I'm new to Grails.</p>