Changeset 3731
- Timestamp:
- 05/28/08 01:02:59 (6 months ago)
- Files:
-
- accountmanagerplugin/trunk/acct_mgr/admin.py (modified) (4 diffs)
- accountmanagerplugin/trunk/acct_mgr/api.py (modified) (2 diffs)
- accountmanagerplugin/trunk/acct_mgr/templates/admin_accountsconfig.html (modified) (1 diff)
- accountmanagerplugin/trunk/acct_mgr/templates/prefs_account.html (modified) (2 diffs)
- accountmanagerplugin/trunk/acct_mgr/web_ui.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
accountmanagerplugin/trunk/acct_mgr/admin.py
r2533 r3731 58 58 self.config.set(option.section, option.name, newvalue) 59 59 self.config.save() 60 self.config.set('account-manager', 'force_passwd_change', 61 req.args.get('force_passwd_change')) 62 self.config.save() 63 64 60 65 try: 61 66 selected = self.account_manager.password_store … … 76 81 ] 77 82 sections = sorted(sections, key=lambda i: i['name']) 78 return 'admin_accountsconfig.html', {'sections': sections} 83 data = {'sections': sections, 84 'force_passwd_change': self.account_manager.force_passwd_change} 85 return 'admin_accountsconfig.html', data 79 86 80 87 def _do_users(self, req): … … 136 143 137 144 # ITemplateProvider 138 145 139 146 def get_htdocs_dirs(self): 140 147 """Return the absolute path of a directory containing additional … … 142 149 """ 143 150 return [] 144 151 145 152 def get_templates_dirs(self): 146 153 """Return the absolute path of the directory containing the provided accountmanagerplugin/trunk/acct_mgr/api.py
r3728 r3731 11 11 12 12 from trac.core import * 13 from trac.config import Option, ExtensionOption13 from trac.config import Option, BoolOption, ExtensionOption 14 14 15 15 class IPasswordStore(Interface): … … 86 86 stores = ExtensionPoint(IPasswordStore) 87 87 change_listeners = ExtensionPoint(IAccountChangeListener) 88 force_passwd_change = BoolOption('account-manager', 'force_passwd_change', 89 True, doc="Forge the user to change " 90 "password when it's reset.") 88 91 89 92 # Public API accountmanagerplugin/trunk/acct_mgr/templates/admin_accountsconfig.html
r1524 r3731 30 30 </div> 31 31 </fieldset> 32 <fieldset> 33 <legend>Password Reset</legend> 34 <label for="force_passwd_change"> 35 Force users to change passwords after a password reset? 36 </label> 37 <input type="radio" name="force_passwd_change" value="true" 38 checked="${force_passwd_change and 'checked' or None}">Yes</input> 39 <input type="radio" name="force_passwd_change" value="false" 40 checked="${not force_passwd_change and 'checked' or None}">No</input> 41 </fieldset> 32 42 <div class="buttons"> 33 43 <input type="submit" name="save" value="Save" /> accountmanagerplugin/trunk/acct_mgr/templates/prefs_account.html
r1709 r3731 35 35 </py:if> 36 36 </div> 37 37 38 38 <head> 39 39 <title>Account</title> … … 45 45 <p>$account.error</p> 46 46 </div> 47 47 <div class="system-message" py:if="account.force_change_passwd"> 48 <h2>Immediate action required</h2> 49 <p>You are required to change password because of a recent 50 password change request.</p> 51 <p><strong>Please change your password now.</strong></p> 52 </div> 48 53 <p py:if="account.message">$account.message</p> 49 54 <h2>Change Password</h2> accountmanagerplugin/trunk/acct_mgr/web_ui.py
r3554 r3731 20 20 from trac.web import auth 21 21 from trac.web.api import IAuthenticator 22 from trac.web.main import IRequestHandler 22 from trac.web.main import IRequestHandler, IRequestFilter 23 23 from trac.web.chrome import INavigationContributor, ITemplateProvider 24 from trac.util import Markup24 from genshi.builder import tag 25 25 26 26 from api import AccountManager … … 120 120 """ 121 121 122 implements(IPreferencePanelProvider, IRequestHandler, ITemplateProvider, INavigationContributor) 122 implements(IPreferencePanelProvider, IRequestHandler, ITemplateProvider, 123 INavigationContributor, IRequestFilter) 123 124 124 125 _password_chars = string.ascii_letters + string.digits 125 password_length = IntOption('account-manager', 'generated_password_length', 8,126 'Length of the randomly-generated passwords '126 password_length = IntOption('account-manager', 'generated_password_length', 127 8, 'Length of the randomly-generated passwords ' 127 128 'created when resetting the password for an ' 128 129 'account.') … … 158 159 return 'reset_password.html', data, None 159 160 161 # IRequestFilter methods 162 def pre_process_request(self, req, handler): 163 return handler 164 165 def post_process_request(self, req, template, data, content_type): 166 if req.authname and req.authname != 'anonymous': 167 if req.session.get('force_change_passwd', False): 168 redirect_url = req.href.prefs('account') 169 if req.path_info != redirect_url: 170 req.redirect(redirect_url) 171 return (template, data, content_type) 172 160 173 # INavigationContributor methods 161 174 def get_active_navigation_item(self, req): … … 166 179 return 167 180 if req.authname == 'anonymous': 168 yield 'metanav', 'reset_password', Markup('<a href="%s">Forgot your password?</a>') % req.href.reset_password() 181 yield 'metanav', 'reset_password', tag.a( 182 "Forgot your password?", href=req.href.reset_password()) 169 183 170 184 def reset_password_enabled(self): … … 180 194 delete_enabled = AccountManager(self.env).supports('delete_user') 181 195 data = {'delete_enabled': delete_enabled} 196 force_change_password = req.session.get('force_change_passwd', False) 197 if force_change_password: 198 data['force_change_passwd'] = True 182 199 if req.method == 'POST': 183 200 if action == 'save': 184 201 data.update(self._do_change_password(req)) 202 if force_change_password: 203 data['force_change_passwd'] = False 204 del(req.session['force_change_passwd']) 205 req.session.save() 185 206 elif action == 'delete' and delete_enabled: 186 207 data.update(self._do_delete(req)) … … 209 230 new_password = self._random_password() 210 231 notifier.notify(username, new_password) 211 AccountManager(self.env).set_password(username, new_password) 232 mgr = AccountManager(self.env) 233 mgr.set_password(username, new_password) 234 if mgr.force_passwd_change: 235 db = self.env.get_db_cnx() 236 cursor = db.cursor() 237 cursor.execute("UPDATE session_attribute SET value=%s " 238 "WHERE name=%s AND sid=%s AND authenticated=1", 239 (1, "force_change_passwd", username)) 240 if not cursor.rowcount: 241 cursor.execute("INSERT INTO session_attribute " 242 "(sid,authenticated,name,value) " 243 "VALUES (%s,1,%s,%s)", 244 (username, "force_change_passwd", 1)) 245 db.commit() 246 212 247 return {'sent_to_email': email} 213 248 … … 250 285 251 286 # ITemplateProvider 252 287 253 288 def get_htdocs_dirs(self): 254 289 """Return the absolute path of a directory containing additional … … 298 333 return 299 334 if req.authname == 'anonymous': 300 yield 'metanav', 'register', Markup('<a href="%s">Register</a>') % req.href.register() 335 yield 'metanav', 'register', tag.a("Register", 336 href=req.href.register()) 337 301 338 302 339 # IRequestHandler methods … … 325 362 326 363 # ITemplateProvider 327 364 328 365 def get_htdocs_dirs(self): 329 366 """Return the absolute path of a directory containing additional … … 402 439 403 440 # ITemplateProvider 404 441 405 442 def get_htdocs_dirs(self): 406 443 """Return the absolute path of a directory containing additional
