diff 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
line wrap: on
line diff
--- a/rhodecode/controllers/login.py	Mon Jul 01 15:39:01 2013 +0200
+++ b/rhodecode/controllers/login.py	Mon Jul 01 16:10:22 2013 +0200
@@ -37,6 +37,7 @@
 import rhodecode.lib.helpers as h
 from rhodecode.lib.auth import AuthUser, HasPermissionAnyDecorator
 from rhodecode.lib.base import BaseController, render
+from rhodecode.lib.exceptions import UserCreationError
 from rhodecode.model.db import User
 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm
 from rhodecode.model.user import UserModel
@@ -120,6 +121,12 @@
                     errors=errors.error_dict or {},
                     prefix_error=False,
                     encoding="UTF-8")
+            except UserCreationError, e:
+                # container auth or other auth functions that create users on
+                # the fly can throw this exception signaling that there's issue
+                # with user creation, explanation should be provided in
+                # Exception itself
+                h.flash(e, 'error')
 
         return render('/login.html')
 
@@ -147,6 +154,12 @@
                     errors=errors.error_dict or {},
                     prefix_error=False,
                     encoding="UTF-8")
+            except UserCreationError, e:
+                # container auth or other auth functions that create users on
+                # the fly can throw this exception signaling that there's issue
+                # with user creation, explanation should be provided in
+                # Exception itself
+                h.flash(e, 'error')
 
         return render('/register.html')