##// END OF EJS Templates
fixes #762, LDAP and container created users are now activated based on...
marcink -
r3370:fdb0f59b beta
parent child Browse files
Show More
@@ -126,20 +126,16 b' class LoginController(BaseController):'
126 126 @HasPermissionAnyDecorator('hg.admin', 'hg.register.auto_activate',
127 127 'hg.register.manual_activate')
128 128 def register(self):
129 c.auto_active = False
130 for perm in User.get_by_username('default').user_perms:
131 if perm.permission.permission_name == 'hg.register.auto_activate':
132 c.auto_active = True
133 break
129 c.auto_active = 'hg.register.auto_activate' in User.get_by_username('default')\
130 .AuthUser.permissions['global']
134 131
135 132 if request.POST:
136
137 133 register_form = RegisterForm()()
138 134 try:
139 135 form_result = register_form.to_python(dict(request.POST))
140 136 form_result['active'] = c.auto_active
141 137 UserModel().create_registration(form_result)
142 h.flash(_('You have successfully registered into rhodecode'),
138 h.flash(_('You have successfully registered into RhodeCode'),
143 139 category='success')
144 140 Session().commit()
145 141 return redirect(url('login_home'))
@@ -226,6 +226,8 b' def authenticate(username, password):'
226 226 'name': safe_unicode(get_ldap_attr('ldap_attr_firstname')),
227 227 'lastname': safe_unicode(get_ldap_attr('ldap_attr_lastname')),
228 228 'email': get_ldap_attr('ldap_attr_email'),
229 'active': 'hg.register.auto_activate' in User\
230 .get_by_username('default').AuthUser.permissions['global']
229 231 }
230 232
231 233 # don't store LDAP password since we don't need it. Override
@@ -254,6 +256,8 b' def login_container_auth(username):'
254 256 'name': username,
255 257 'lastname': None,
256 258 'email': None,
259 'active': 'hg.register.auto_activate' in User\
260 .get_by_username('default').AuthUser.permissions['global']
257 261 }
258 262 user = UserModel().create_for_container_auth(username, user_attrs)
259 263 if not user:
@@ -399,6 +399,15 b' class User(Base, BaseModel):'
399 399 def is_admin(self):
400 400 return self.admin
401 401
402 @property
403 def AuthUser(self):
404 """
405 Returns instance of AuthUser for this user
406 """
407 from rhodecode.lib.auth import AuthUser
408 return AuthUser(user_id=self.user_id, api_key=self.api_key,
409 username=self.username)
410
402 411 def __unicode__(self):
403 412 return u"<%s('id:%s:%s')>" % (self.__class__.__name__,
404 413 self.user_id, self.username)
General Comments 0
You need to be logged in to leave comments. Login now