##// END OF EJS Templates
users: make AuthUser propert a method, and allow override of params.
marcink -
r1997:61825b68 default
parent child
Show More
@@ -116,7 +116,7 class TestGetRepos(object):
116 116 response = api_call(self.app, params)
117 117
118 118 user = User.get_by_username(self.TEST_USER_LOGIN)
119 allowed_repos = user.AuthUser.permissions['repositories']
119 allowed_repos = user.AuthUser().permissions['repositories']
120 120
121 121 result = []
122 122 for repo in RepoModel().get_all():
@@ -309,7 +309,7 class AdminPermissionsView(BaseAppView):
309 309 c.active = 'perms'
310 310
311 311 c.user = User.get_default_user(refresh=True)
312 c.perm_user = c.user.AuthUser
312 c.perm_user = c.user.AuthUser()
313 313 return self._get_template_context(c)
314 314
315 315 @LoginRequired()
@@ -324,7 +324,7 class AdminPermissionsView(BaseAppView):
324 324 c.active = 'auth_token_access'
325 325
326 326 c.user = User.get_default_user(refresh=True)
327 c.perm_user = c.user.AuthUser
327 c.perm_user = c.user.AuthUser()
328 328
329 329 mapper = self.request.registry.queryUtility(IRoutesMapper)
330 330 c.view_data = []
@@ -60,7 +60,7 class TestRegisterCaptcha(object):
60 60 ])
61 61 def test_get_captcha_data(self, private_key, public_key, expected, db,
62 62 request_stub, user_util):
63 request_stub.user = user_util.create_user().AuthUser
63 request_stub.user = user_util.create_user().AuthUser()
64 64 request_stub.matched_route = AttributeDict({'name': 'login'})
65 65 login_view = LoginView(mock.Mock(), request_stub)
66 66
@@ -231,7 +231,7 class LoginView(BaseAppView):
231 231 register_message = settings.get('rhodecode_register_message') or ''
232 232 captcha = self._get_captcha_data()
233 233 auto_active = 'hg.register.auto_activate' in User.get_default_user()\
234 .AuthUser.permissions['global']
234 .AuthUser().permissions['global']
235 235
236 236 render_ctx = self._get_template_context(c)
237 237 render_ctx.update({
@@ -252,7 +252,7 class LoginView(BaseAppView):
252 252 def register_post(self):
253 253 captcha = self._get_captcha_data()
254 254 auto_active = 'hg.register.auto_activate' in User.get_default_user()\
255 .AuthUser.permissions['global']
255 .AuthUser().permissions['global']
256 256
257 257 register_form = RegisterForm()()
258 258 try:
@@ -317,7 +317,7 def summary_view(context_stub, request_s
317 317 """
318 318 request_stub.matched_route = AttributeDict(name='test_view')
319 319
320 request_stub.user = user_util.create_user().AuthUser
320 request_stub.user = user_util.create_user().AuthUser()
321 321 request_stub.db_repo = user_util.create_repo()
322 322
323 323 view = RepoSummaryView(context=context_stub, request=request_stub)
@@ -223,7 +223,7 class RhodeCodeAuthPlugin(RhodeCodeExter
223 223 return True
224 224
225 225 def user_activation_state(self):
226 def_user_perms = User.get_default_user().AuthUser.permissions['global']
226 def_user_perms = User.get_default_user().AuthUser().permissions['global']
227 227 return 'hg.extern_activate.auto' in def_user_perms
228 228
229 229 def auth(self, userobj, username, password, settings, **kwargs):
@@ -112,7 +112,7 class RhodeCodeAuthPlugin(RhodeCodeExter
112 112 return True
113 113
114 114 def user_activation_state(self):
115 def_user_perms = User.get_default_user().AuthUser.permissions['global']
115 def_user_perms = User.get_default_user().AuthUser().permissions['global']
116 116 return 'hg.extern_activate.auto' in def_user_perms
117 117
118 118 def _clean_username(self, username):
@@ -103,7 +103,7 class RhodeCodeAuthPlugin(RhodeCodeExter
103 103 return True
104 104
105 105 def user_activation_state(self):
106 def_user_perms = User.get_default_user().AuthUser.permissions['global']
106 def_user_perms = User.get_default_user().AuthUser().permissions['global']
107 107 return 'hg.extern_activate.auto' in def_user_perms
108 108
109 109 def auth(self, userobj, username, password, settings, **kwargs):
@@ -374,7 +374,7 class RhodeCodeAuthPlugin(RhodeCodeExter
374 374 return True
375 375
376 376 def user_activation_state(self):
377 def_user_perms = User.get_default_user().AuthUser.permissions['global']
377 def_user_perms = User.get_default_user().AuthUser().permissions['global']
378 378 return 'hg.extern_activate.auto' in def_user_perms
379 379
380 380 def try_dynamic_binding(self, username, password, current_args):
@@ -71,7 +71,7 class RhodeCodeAuthPlugin(RhodeCodeAuthP
71 71 return "rhodecode"
72 72
73 73 def user_activation_state(self):
74 def_user_perms = User.get_default_user().AuthUser.permissions['global']
74 def_user_perms = User.get_default_user().AuthUser().permissions['global']
75 75 return 'hg.register.auto_activate' in def_user_perms
76 76
77 77 def allows_authentication_from(
@@ -74,7 +74,7 class RhodeCodeAuthPlugin(RhodeCodeAuthP
74 74 return "authtoken"
75 75
76 76 def user_activation_state(self):
77 def_user_perms = User.get_default_user().AuthUser.permissions['global']
77 def_user_perms = User.get_default_user().AuthUser().permissions['global']
78 78 return 'hg.register.auto_activate' in def_user_perms
79 79
80 80 def allows_authentication_from(
@@ -743,13 +743,12 class User(Base, BaseModel):
743 743 def is_admin(self):
744 744 return self.admin
745 745
746 @property
747 def AuthUser(self):
746 def AuthUser(self, **kwargs):
748 747 """
749 748 Returns instance of AuthUser for this user
750 749 """
751 750 from rhodecode.lib.auth import AuthUser
752 return AuthUser(user_id=self.user_id, username=self.username)
751 return AuthUser(user_id=self.user_id, username=self.username, **kwargs)
753 752
754 753 @hybrid_property
755 754 def user_data(self):
@@ -56,7 +56,7 class RhodeCodeAuthPlugin(RhodeCodeExter
56 56 return True
57 57
58 58 def user_activation_state(self):
59 def_user_perms = User.get_default_user().AuthUser.permissions['global']
59 def_user_perms = User.get_default_user().AuthUser().permissions['global']
60 60 return 'hg.extern_activate.auto' in def_user_perms
61 61
62 62 def auth(self, userobj, username, password, settings, **kwargs):
General Comments 0
You need to be logged in to leave comments. Login now