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