Index: main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py	(revision 8857)
+++ main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py	(revision 8858)
@@ -26,4 +26,5 @@
 import time
 import re
+from urllib import urlencode
 from zope import schema
 from zope.authentication.interfaces import (
@@ -67,4 +68,5 @@
 from waeup.kofa.authentication import get_principal_role_manager
 from waeup.kofa.utils.helpers import get_user_account, msave
+from waeup.kofa.mandates.mandate import PasswordMandate
 
 grok.context(IKofaObject)
@@ -2124,16 +2126,17 @@
         # Change password
         kofa_utils = getUtility(IKofaUtils)
-        pwd = kofa_utils.genPassword()
-
-        ###: To be changed
-        IUserAccount(user).setPassword(pwd)
-
-
-        # Send email with new credentials
-        msg = _('You have successfully changed your password for the')
-        login_url = self.url(grok.getSite(), 'login')
-        url_info = u'Login: %s' % login_url
+        password = kofa_utils.genPassword()
+        mandate = PasswordMandate()
+        mandate.params['password'] = password
+        mandate.params['user'] = user
+        site = grok.getSite()
+        site['mandates'].addMandate(mandate)
+        # Send email with credentials
+        args = {'mandate_id':mandate.mandate_id}
+        mandate_url = self.url(site) + '/mandate?%s' % urlencode(args)
+        url_info = u'Confirmation link: %s' % mandate_url
+        msg = _('You have successfully requested a password for the')
         success = kofa_utils.sendCredentials(
-            IUserAccount(user),pwd,url_info,msg)
+            IUserAccount(user),password,url_info,msg)
         if success:
             self.flash(_('An email with your user name and password ' +
Index: main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py	(revision 8857)
+++ main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py	(revision 8858)
@@ -55,15 +55,12 @@
 
     def _setPassword(self):
-        user_id = self.params.get('user_id', None)
+        user = self.params.get('user', None)
         pwd = self.params.get('password', None)
-        user_type = self.params.get('user_type', None)
-        user = None
-        if user_type == 'student':
-            user = grok.getSite()['students'].get(user_id, None)
-        elif user_type == 'officer':
-            user = grok.getSite()['users'].get(user_id, None)
         if user and pwd:
-            IUserAccount(user).setPassword(pwd)
-            return True
+            try:
+                IUserAccount(user).setPassword(pwd)
+                return True
+            except:
+                return False
         return False
 
Index: main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py	(revision 8857)
+++ main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py	(revision 8858)
@@ -99,7 +99,6 @@
         # Add and execute a perfect mandate
         mandate = PasswordMandate()
-        mandate.params['user_id'] = student.student_id
+        mandate.params['user'] = student
         mandate.params['password'] = 'mypwd1'
-        mandate.params['user_type'] = 'student'
         self.app['mandates'].addMandate(mandate)
         msg = mandate.execute()
@@ -115,7 +114,6 @@
         officer = self.app['users']['bob']
         mandate = PasswordMandate()
-        mandate.params['user_id'] = 'bob'
+        mandate.params['user'] = officer
         mandate.params['password'] = 'mypwd1'
-        mandate.params['user_type'] = 'officer'
         self.app['mandates'].addMandate(mandate)
         msg = mandate.execute()
@@ -142,6 +140,5 @@
         self.app['students'].addStudent(student)
         mandate = PasswordMandate()
-        mandate.params['user_id'] = student.student_id
-        mandate.params['user_type'] = 'student'
+        mandate.params['user'] = student
         mandate.params['password'] = 'mypwd1'
         self.app['mandates'].addMandate(mandate)
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 8857)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 8858)
@@ -1989,6 +1989,5 @@
         mandate = PasswordMandate()
         mandate.params['password'] = password
-        mandate.params['student_id'] = student.student_id
-        mandate.params['user_type'] = 'student'
+        mandate.params['user'] = student
         site = grok.getSite()
         site['mandates'].addMandate(mandate)
