##// END OF EJS Templates
auth: login/registration changes for upcomming new rules for login using external identities....
marcink -
r3386:e8cf67e0 default
parent child Browse files
Show More
@@ -74,20 +74,17 b' class TestPasswordReset(TestController):'
74 74 'default_password_reset': pwd_reset_setting,
75 75 'default_extern_activate': 'hg.extern_activate.auto',
76 76 }
77 resp = self.app.post(route_path('admin_permissions_application_update'), params=params)
77 resp = self.app.post(
78 route_path('admin_permissions_application_update'), params=params)
78 79 self.logout_user()
79 80
80 81 login_page = self.app.get(route_path('login'))
81 82 asr_login = AssertResponse(login_page)
82 index_page = self.app.get(h.route_path('home'))
83 asr_index = AssertResponse(index_page)
84 83
85 84 if show_link:
86 85 asr_login.one_element_exists('a.pwd_reset')
87 asr_index.one_element_exists('a.pwd_reset')
88 86 else:
89 87 asr_login.no_element_exists('a.pwd_reset')
90 asr_index.no_element_exists('a.pwd_reset')
91 88
92 89 response = self.app.get(route_path('reset_password'))
93 90
@@ -24,6 +24,9 b' RhodeCode authentication plugin for buil'
24 24
25 25 import logging
26 26
27 import colander
28
29 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
27 30 from rhodecode.translation import _
28 31
29 32 from rhodecode.authentication.base import RhodeCodeAuthPluginBase, hybrid_property
@@ -43,6 +46,18 b' class RhodecodeAuthnResource(AuthnPlugin'
43 46 pass
44 47
45 48
49 class RhodeCodeSettingsSchema(AuthnPluginSettingsSchemaBase):
50
51 superadmin_restriction = colander.SchemaNode(
52 colander.Bool(),
53 default=False,
54 description=_('Only allow super-admins to log-in using this plugin.'),
55 missing=False,
56 title=_('Enabled'),
57 widget='bool',
58 )
59
60
46 61 class RhodeCodeAuthPlugin(RhodeCodeAuthPluginBase):
47 62 uid = 'rhodecode'
48 63
@@ -64,6 +79,9 b' class RhodeCodeAuthPlugin(RhodeCodeAuthP'
64 79 route_name='auth_home',
65 80 context=RhodecodeAuthnResource)
66 81
82 def get_settings_schema(self):
83 return RhodeCodeSettingsSchema()
84
67 85 def get_display_name(self):
68 86 return _('RhodeCode Internal')
69 87
@@ -650,10 +650,9 b' flash = Flash()'
650 650 # SCM FILTERS available via h.
651 651 #==============================================================================
652 652 from rhodecode.lib.vcs.utils import author_name, author_email
653 from rhodecode.lib.utils2 import credentials_filter, age as _age
653 from rhodecode.lib.utils2 import credentials_filter, age, age_from_seconds
654 654 from rhodecode.model.db import User, ChangesetStatus
655 655
656 age = _age
657 656 capitalize = lambda x: x.capitalize()
658 657 email = author_email
659 658 short_id = lambda x: x[:12]
@@ -564,6 +564,12 b' def age(prevdate, now=None, show_short_v'
564 564 return _(u'just now')
565 565
566 566
567 def age_from_seconds(seconds):
568 seconds = safe_int(seconds) or 0
569 prevdate = time_to_datetime(time.time() + seconds)
570 return age(prevdate, show_suffix=False, show_short_version=True)
571
572
567 573 def cleaned_uri(uri):
568 574 """
569 575 Quotes '[' and ']' from uri if there is only one of them.
@@ -73,9 +73,6 b''
73 73 }
74 74
75 75 .sign-in-title {
76 h1 {
77 margin: 0;
78 }
79 76
80 77 h4 {
81 78 margin: @padding*2 0;
@@ -299,87 +299,54 b''
299 299 <%def name="usermenu(active=False)">
300 300 ## USER MENU
301 301 <li id="quick_login_li" class="${'active' if active else ''}">
302 <a id="quick_login_link" class="menulink childs">
303 ${gravatar(c.rhodecode_user.email, 20)}
304 <span class="user">
305 %if c.rhodecode_user.username != h.DEFAULT_USER:
306 <span class="menu_link_user">${c.rhodecode_user.username}</span><div class="show_more"></div>
307 %else:
308 <span>${_('Sign in')}</span>
309 %endif
310 </span>
311 </a>
312
313 <div class="user-menu submenu">
314 <div id="quick_login">
315 %if c.rhodecode_user.username == h.DEFAULT_USER:
316 <h4>${_('Sign in to your account')}</h4>
317 ${h.form(h.route_path('login', _query={'came_from': h.current_route_path(request)}), needs_csrf_token=False)}
318 <div class="form form-vertical">
319 <div class="fields">
320 <div class="field">
321 <div class="label">
322 <label for="username">${_('Username')}:</label>
323 </div>
324 <div class="input">
325 ${h.text('username',class_='focus',tabindex=1)}
326 </div>
327
328 </div>
329 <div class="field">
330 <div class="label">
331 <label for="password">${_('Password')}:</label>
332 %if h.HasPermissionAny('hg.password_reset.enabled')():
333 <span class="forgot_password">${h.link_to(_('(Forgot password?)'),h.route_path('reset_password'), class_='pwd_reset')}</span>
334 %endif
335 </div>
336 <div class="input">
337 ${h.password('password',class_='focus',tabindex=2)}
338 </div>
302 % if c.rhodecode_user.username == h.DEFAULT_USER:
303 <a id="quick_login_link" class="menulink childs" href="${h.route_path('login', _query={'came_from': h.current_route_path(request)})}">
304 ${gravatar(c.rhodecode_user.email, 20)}
305 <span class="user">
306 <span>${_('Sign in')}</span>
307 </span>
308 </a>
309 % else:
310 ## logged in user
311 <a id="quick_login_link" class="menulink childs">
312 ${gravatar(c.rhodecode_user.email, 20)}
313 <span class="user">
314 <span class="menu_link_user">${c.rhodecode_user.username}</span>
315 <div class="show_more"></div>
316 </span>
317 </a>
318 ## subnav with menu for logged in user
319 <div class="user-menu submenu">
320 <div id="quick_login">
321 %if c.rhodecode_user.username != h.DEFAULT_USER:
322 <div class="">
323 <div class="big_gravatar">${gravatar(c.rhodecode_user.email, 48)}</div>
324 <div class="full_name">${c.rhodecode_user.full_name_or_username}</div>
325 <div class="email">${c.rhodecode_user.email}</div>
339 326 </div>
340 <div class="buttons">
341 <div class="register">
342 %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')():
343 ${h.link_to(_("Don't have an account?"),h.route_path('register'))} <br/>
344 %endif
345 ${h.link_to(_("Using external auth? Sign In here."),h.route_path('login'))}
346 </div>
347 <div class="submit">
348 ${h.submit('sign_in',_('Sign In'),class_="btn btn-small",tabindex=3)}
349 </div>
327 <div class="">
328 <ol class="links">
329 <li>${h.link_to(_(u'My account'),h.route_path('my_account_profile'))}</li>
330 % if c.rhodecode_user.personal_repo_group:
331 <li>${h.link_to(_(u'My personal group'), h.route_path('repo_group_home', repo_group_name=c.rhodecode_user.personal_repo_group.group_name))}</li>
332 % endif
333 <li>${h.link_to(_(u'Pull Requests'), h.route_path('my_account_pullrequests'))}</li>
334
335 <li class="logout">
336 ${h.secure_form(h.route_path('logout'), request=request)}
337 ${h.submit('log_out', _(u'Sign Out'),class_="btn btn-primary")}
338 ${h.end_form()}
339 </li>
340 </ol>
350 341 </div>
351 </div>
352 </div>
353 ${h.end_form()}
354 %else:
355 <div class="">
356 <div class="big_gravatar">${gravatar(c.rhodecode_user.email, 48)}</div>
357 <div class="full_name">${c.rhodecode_user.full_name_or_username}</div>
358 <div class="email">${c.rhodecode_user.email}</div>
359 </div>
360 <div class="">
361 <ol class="links">
362 <li>${h.link_to(_(u'My account'),h.route_path('my_account_profile'))}</li>
363 % if c.rhodecode_user.personal_repo_group:
364 <li>${h.link_to(_(u'My personal group'), h.route_path('repo_group_home', repo_group_name=c.rhodecode_user.personal_repo_group.group_name))}</li>
365 % endif
366 <li>${h.link_to(_(u'Pull Requests'), h.route_path('my_account_pullrequests'))}</li>
367
368 <li class="logout">
369 ${h.secure_form(h.route_path('logout'), request=request)}
370 ${h.submit('log_out', _(u'Sign Out'),class_="btn btn-primary")}
371 ${h.end_form()}
372 </li>
373 </ol>
374 </div>
375 %endif
376 </div>
377 </div>
378 %if c.rhodecode_user.username != h.DEFAULT_USER:
379 <div class="pill_container">
380 <a class="menu_link_notifications ${'empty' if c.unread_notifications == 0 else ''}" href="${h.route_path('notifications_show_all')}">${c.unread_notifications}</a>
381 </div>
382 % endif
342 %endif
343 </div>
344 </div>
345 ## unread counter
346 <div class="pill_container">
347 <a class="menu_link_notifications ${'empty' if c.unread_notifications == 0 else ''}" href="${h.route_path('notifications_show_all')}">${c.unread_notifications}</a>
348 </div>
349 % endif
383 350 </li>
384 351 </%def>
385 352
@@ -25,17 +25,16 b''
25 25
26 26 <div class="loginwrapper">
27 27 <rhodecode-toast id="notifications"></rhodecode-toast>
28
28 29 <div class="left-column">
29 30 <img class="sign-in-image" src="${h.asset('images/sign-in.png')}" alt="RhodeCode"/>
30 31 </div>
32
31 33 <%block name="above_login_button" />
32 34 <div id="login" class="right-column">
33 35 <!-- login -->
34 36 <div class="sign-in-title">
35 <h1>${_('Sign In')}</h1>
36 %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')():
37 <h4>${h.link_to(_("Go to the registration page to create a new account."), request.route_path('register'))}</h4>
38 %endif
37 <h1>${_('Sign In using username/password')}</h1>
39 38 </div>
40 39 <div class="inner form">
41 40 ${h.form(request.route_path('login', _query={'came_from': c.came_from}), needs_csrf_token=False)}
@@ -47,7 +46,12 b''
47 46 <br />
48 47 %endif
49 48
50 <label for="password">${_('Password')}:</label>
49 <label for="password">${_('Password')}:
50 %if h.HasPermissionAny('hg.password_reset.enabled')():
51 <div class="pull-right">${h.link_to(_('Forgot your password?'), h.route_path('reset_password'), class_='pwd_reset', tabindex="-1")}</div>
52 %endif
53
54 </label>
51 55 ${h.password('password', class_='focus')}
52 56 %if 'password' in errors:
53 57 <span class="error-message">${errors.get('password')}</span>
@@ -55,15 +59,25 b''
55 59 %endif
56 60
57 61 ${h.checkbox('remember', value=True, checked=defaults.get('remember'))}
58 <label class="checkbox" for="remember">${_('Remember me')}</label>
62 <% timeout = request.registry.settings.get('beaker.session.timeout', '0') %>
63 % if timeout == '0':
64 <% remember_label = _('Remember my indefinitely') %>
65 % else:
66 <% remember_label = _('Remember me for {}').format(h.age_from_seconds(timeout)) %>
67 % endif
68 <label class="checkbox" for="remember">${remember_label}</label>
59 69
60 %if h.HasPermissionAny('hg.password_reset.enabled')():
61 <p class="links">
62 ${h.link_to(_('Forgot your password?'), h.route_path('reset_password'), class_='pwd_reset')}
63 </p>
64 %elif h.HasPermissionAny('hg.password_reset.hidden')():
70 <p class="links">
71 %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')():
72 ${h.link_to(_("Create a new account."), request.route_path('register'))}
73 %endif
74 </p>
75
76 %if not h.HasPermissionAny('hg.password_reset.enabled')():
77 ## password reset hidden or disabled.
65 78 <p class="help-block">
66 ${_('Password reset is disabled. Please contact ')}
79 ${_('Password reset is disabled.')} <br/>
80 ${_('Please contact ')}
67 81 % if c.visual.rhodecode_support_url:
68 82 <a href="${c.visual.rhodecode_support_url}" target="_blank">${_('Support')}</a>
69 83 ${_('or')}
@@ -72,18 +86,18 b''
72 86 </p>
73 87 %endif
74 88
75 ${h.submit('sign_in', _('Sign In'), class_="btn sign-in")}
76 <p class="help-block pull-right">
77 RhodeCode ${c.rhodecode_edition}
78 </p>
89 ${h.submit('sign_in', _('Sign In'), class_="btn sign-in", title=_('Sign in to {}').format(c.rhodecode_edition))}
90
79 91 ${h.end_form()}
80 92 <script type="text/javascript">
81 93 $(document).ready(function(){
82 94 $('#username').focus();
83 95 })
84 96 </script>
97
85 98 </div>
86 99 <!-- end login -->
100
87 101 <%block name="below_login_button" />
88 102 </div>
89 103 </div>
@@ -118,10 +118,7 b''
118 118 ${register_message|n}
119 119 </p>
120 120
121 ${h.submit('sign_up',_('Create Account'),class_="btn sign-in")}
122 <p class="help-block pull-right">
123 RhodeCode ${c.rhodecode_edition}
124 </p>
121 ${h.submit('sign_up',_('Create Account'), class_="btn sign-in", title=_('Create Account in {}').format(c.rhodecode_edition))}
125 122 ${h.end_form()}
126 123 </div>
127 124 <%block name="below_register_button" />
General Comments 0
You need to be logged in to leave comments. Login now