comparison rhodecode/controllers/login.py @ 4074:3b136af34329

Added pre-create user hook. It allows to control user creation using rcext hooks.
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 01 Jul 2013 16:10:22 +0200
parents 5293d4bbb1ea
children b59568e929ef
comparison
equal deleted inserted replaced
4073:2c82dd8ba318 4074:3b136af34329
35 from pylons import request, response, session, tmpl_context as c, url 35 from pylons import request, response, session, tmpl_context as c, url
36 36
37 import rhodecode.lib.helpers as h 37 import rhodecode.lib.helpers as h
38 from rhodecode.lib.auth import AuthUser, HasPermissionAnyDecorator 38 from rhodecode.lib.auth import AuthUser, HasPermissionAnyDecorator
39 from rhodecode.lib.base import BaseController, render 39 from rhodecode.lib.base import BaseController, render
40 from rhodecode.lib.exceptions import UserCreationError
40 from rhodecode.model.db import User 41 from rhodecode.model.db import User
41 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm 42 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm
42 from rhodecode.model.user import UserModel 43 from rhodecode.model.user import UserModel
43 from rhodecode.model.meta import Session 44 from rhodecode.model.meta import Session
44 45
118 render('/login.html'), 119 render('/login.html'),
119 defaults=errors.value, 120 defaults=errors.value,
120 errors=errors.error_dict or {}, 121 errors=errors.error_dict or {},
121 prefix_error=False, 122 prefix_error=False,
122 encoding="UTF-8") 123 encoding="UTF-8")
124 except UserCreationError, e:
125 # container auth or other auth functions that create users on
126 # the fly can throw this exception signaling that there's issue
127 # with user creation, explanation should be provided in
128 # Exception itself
129 h.flash(e, 'error')
123 130
124 return render('/login.html') 131 return render('/login.html')
125 132
126 @HasPermissionAnyDecorator('hg.admin', 'hg.register.auto_activate', 133 @HasPermissionAnyDecorator('hg.admin', 'hg.register.auto_activate',
127 'hg.register.manual_activate') 134 'hg.register.manual_activate')
145 render('/register.html'), 152 render('/register.html'),
146 defaults=errors.value, 153 defaults=errors.value,
147 errors=errors.error_dict or {}, 154 errors=errors.error_dict or {},
148 prefix_error=False, 155 prefix_error=False,
149 encoding="UTF-8") 156 encoding="UTF-8")
157 except UserCreationError, e:
158 # container auth or other auth functions that create users on
159 # the fly can throw this exception signaling that there's issue
160 # with user creation, explanation should be provided in
161 # Exception itself
162 h.flash(e, 'error')
150 163
151 return render('/register.html') 164 return render('/register.html')
152 165
153 def password_reset(self): 166 def password_reset(self):
154 if request.POST: 167 if request.POST: