aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/model
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2012-06-18 21:25:49 +0200
committerMarcin Kuzminski <marcin@python-works.com>2012-06-18 21:25:49 +0200
commit02d6cc4503aa3f46d2b07186a5266e9407715676 (patch)
tree65c8747c91a5946308772db57d76ecebef6b27f4 /rhodecode/model
parent2d988da18391803efa112ab793ee3820af84516e (diff)
Added validation into user email map
--HG-- branch : beta
Diffstat (limited to 'rhodecode/model')
-rw-r--r--rhodecode/model/forms.py7
-rw-r--r--rhodecode/model/user.py13
-rw-r--r--rhodecode/model/validators.py3
3 files changed, 17 insertions, 6 deletions
diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py
index 6c558e53..033f1540 100644
--- a/rhodecode/model/forms.py
+++ b/rhodecode/model/forms.py
@@ -299,3 +299,10 @@ def LdapSettingsForm(tls_reqcert_choices, search_scope_choices,
ldap_attr_email = v.UnicodeString(strip=True,)
return _LdapSettingsForm
+
+
+def UserExtraEmailForm():
+ class _UserExtraEmailForm(formencode.Schema):
+ email = All(v.UniqSystemEmail(), v.Email)
+
+ return _UserExtraEmailForm \ No newline at end of file
diff --git a/rhodecode/model/user.py b/rhodecode/model/user.py
index 855c5f18..7b282f2b 100644
--- a/rhodecode/model/user.py
+++ b/rhodecode/model/user.py
@@ -29,9 +29,11 @@ import traceback
from pylons import url
from pylons.i18n.translation import _
+from sqlalchemy.exc import DatabaseError
+from sqlalchemy.orm import joinedload
+
from rhodecode.lib.utils2 import safe_unicode, generate_api_key
from rhodecode.lib.caching_query import FromCache
-
from rhodecode.model import BaseModel
from rhodecode.model.db import User, UserRepoToPerm, Repository, Permission, \
UserToPerm, UsersGroupRepoToPerm, UsersGroupToPerm, UsersGroupMember, \
@@ -40,9 +42,6 @@ from rhodecode.model.db import User, UserRepoToPerm, Repository, Permission, \
from rhodecode.lib.exceptions import DefaultUserException, \
UserOwnsReposException
-from sqlalchemy.exc import DatabaseError
-
-from sqlalchemy.orm import joinedload
log = logging.getLogger(__name__)
@@ -593,10 +592,14 @@ class UserModel(BaseModel):
:param user:
:param email:
"""
+ from rhodecode.model import forms
+ form = forms.UserExtraEmailForm()()
+ data = form.to_python(dict(email=email))
user = self._get_user(user)
+
obj = UserEmailMap()
obj.user = user
- obj.email = email
+ obj.email = data['email']
self.sa.add(obj)
return obj
diff --git a/rhodecode/model/validators.py b/rhodecode/model/validators.py
index 9cb5e6f6..da0361a0 100644
--- a/rhodecode/model/validators.py
+++ b/rhodecode/model/validators.py
@@ -14,7 +14,6 @@ from formencode.validators import (
from rhodecode.lib.utils import repo_name_slug
from rhodecode.model.db import RepoGroup, Repository, UsersGroup, User
-from rhodecode.lib.auth import authenticate
from rhodecode.lib.exceptions import LdapImportError
from rhodecode.config.routing import ADMIN_PREFIX
# silence warnings and pylint
@@ -241,6 +240,8 @@ def ValidAuth():
}
def validate_python(self, value, state):
+ from rhodecode.lib.auth import authenticate
+
password = value['password']
username = value['username']