Mercurial > kallithea
annotate rhodecode/controllers/login.py @ 1219:ca614631c2f8
fixed tests for stable
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 05 Apr 2011 20:09:34 +0200 |
parents | a3b2b4b4e440 |
children | bf263968da47 |
rev | line source |
---|---|
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
1 # -*- coding: utf-8 -*- |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
2 """ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
3 rhodecode.controllers.login |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
5 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
6 Login controller for rhodeocode |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
7 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
8 :created_on: Apr 22, 2010 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
9 :author: marcink |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
12 """ |
1217
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
861
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
861
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
861
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
861
diff
changeset
|
16 # (at your option) any later version. |
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
861
diff
changeset
|
17 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
202
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
202
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
202
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
202
diff
changeset
|
21 # GNU General Public License for more details. |
1217
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
861
diff
changeset
|
22 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
202
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
1217
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
861
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
363
diff
changeset
|
25 |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
26 import logging |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
27 import formencode |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
28 |
363
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
29 from formencode import htmlfill |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
30 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
31 from pylons.i18n.translation import _ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
32 from pylons.controllers.util import abort, redirect |
363
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
33 from pylons import request, response, session, tmpl_context as c, url |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
34 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
35 import rhodecode.lib.helpers as h |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
474
diff
changeset
|
36 from rhodecode.lib.auth import AuthUser, HasPermissionAnyDecorator |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
474
diff
changeset
|
37 from rhodecode.lib.base import BaseController, render |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
474
diff
changeset
|
38 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
39 from rhodecode.model.user import UserModel |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
40 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 log = logging.getLogger(__name__) |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 class LoginController(BaseController): |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 |
202
3fd2af1ba5ea
updated logging in logout. Added before, on login page.
Marcin Kuzminski <marcin@python-works.com>
parents:
195
diff
changeset
|
46 def __before__(self): |
3fd2af1ba5ea
updated logging in logout. Added before, on login page.
Marcin Kuzminski <marcin@python-works.com>
parents:
195
diff
changeset
|
47 super(LoginController, self).__before__() |
3fd2af1ba5ea
updated logging in logout. Added before, on login page.
Marcin Kuzminski <marcin@python-works.com>
parents:
195
diff
changeset
|
48 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 def index(self): |
195
7109d15c6813
cleared prints leftoovers, and changed current user fetching in login controller
Marcin Kuzminski <marcin@python-works.com>
parents:
186
diff
changeset
|
50 #redirect if already logged in |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
51 c.came_from = request.GET.get('came_from', None) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
52 |
673
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
53 if c.rhodecode_user.is_authenticated \ |
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
54 and c.rhodecode_user.username != 'default': |
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
55 |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
56 return redirect(url('home')) |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
57 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 if request.POST: |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 #import Login Form validator class |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 login_form = LoginForm() |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 try: |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 c.form_result = login_form.to_python(dict(request.POST)) |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
63 username = c.form_result['username'] |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
64 user = UserModel().get_by_username(username, case_insensitive=True) |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
65 auth_user = AuthUser() |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
66 auth_user.username = user.username |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
67 auth_user.is_authenticated = True |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
68 auth_user.is_admin = user.admin |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
69 auth_user.user_id = user.user_id |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
70 auth_user.name = user.name |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
71 auth_user.lastname = user.lastname |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
72 session['rhodecode_user'] = auth_user |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
73 session.save() |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
74 log.info('user %s is now authenticated', username) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
75 |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
76 user.update_lastlogin() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
77 |
437
930f8182a884
Added redirection to page that request came from, after login in
Marcin Kuzminski <marcin@python-works.com>
parents:
424
diff
changeset
|
78 if c.came_from: |
930f8182a884
Added redirection to page that request came from, after login in
Marcin Kuzminski <marcin@python-works.com>
parents:
424
diff
changeset
|
79 return redirect(c.came_from) |
930f8182a884
Added redirection to page that request came from, after login in
Marcin Kuzminski <marcin@python-works.com>
parents:
424
diff
changeset
|
80 else: |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
81 return redirect(url('home')) |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
82 |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
83 except formencode.Invalid, errors: |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 return htmlfill.render( |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
85 render('/login.html'), |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 defaults=errors.value, |
360
db187729c40c
new style error display for login
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
87 errors=errors.error_dict or {}, |
db187729c40c
new style error display for login
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
88 prefix_error=False, |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
89 encoding="UTF-8") |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
90 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
91 return render('/login.html') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
92 |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
93 @HasPermissionAnyDecorator('hg.admin', 'hg.register.auto_activate', |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
437
diff
changeset
|
94 'hg.register.manual_activate') |
363
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
95 def register(self): |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
363
diff
changeset
|
96 user_model = UserModel() |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
363
diff
changeset
|
97 c.auto_active = False |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
98 for perm in user_model.get_by_username('default', cache=False).user_perms: |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
363
diff
changeset
|
99 if perm.permission.permission_name == 'hg.register.auto_activate': |
418
63c697d1a631
added logic for changin defualt permissions, and option to overwrite all defualt permissions on each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
100 c.auto_active = True |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
363
diff
changeset
|
101 break |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
102 |
363
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
103 if request.POST: |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
104 |
363
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
105 register_form = RegisterForm()() |
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
106 try: |
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
107 form_result = register_form.to_python(dict(request.POST)) |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
363
diff
changeset
|
108 form_result['active'] = c.auto_active |
363
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
109 user_model.create_registration(form_result) |
549
f99075170eb4
more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
110 h.flash(_('You have successfully registered into rhodecode'), |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
111 category='success') |
363
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
112 return redirect(url('login_home')) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
113 |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
114 except formencode.Invalid, errors: |
363
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
115 return htmlfill.render( |
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
116 render('/register.html'), |
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
117 defaults=errors.value, |
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
118 errors=errors.error_dict or {}, |
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
119 prefix_error=False, |
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
120 encoding="UTF-8") |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
121 |
363
98abf8953b87
Added user registration, changed login url schema, moved it into _admin/ for safety
Marcin Kuzminski <marcin@python-works.com>
parents:
360
diff
changeset
|
122 return render('/register.html') |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
123 |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
124 def password_reset(self): |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
125 user_model = UserModel() |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
126 if request.POST: |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
127 |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
128 password_reset_form = PasswordResetForm()() |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
129 try: |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
130 form_result = password_reset_form.to_python(dict(request.POST)) |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
131 user_model.reset_password(form_result) |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
132 h.flash(_('Your new password was sent'), |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
133 category='success') |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
134 return redirect(url('login_home')) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
135 |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
136 except formencode.Invalid, errors: |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
137 return htmlfill.render( |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
138 render('/password_reset.html'), |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
139 defaults=errors.value, |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
140 errors=errors.error_dict or {}, |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
141 prefix_error=False, |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
142 encoding="UTF-8") |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
143 |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
144 return render('/password_reset.html') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
145 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
146 def logout(self): |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
147 session['rhodecode_user'] = AuthUser() |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
148 session.save() |
202
3fd2af1ba5ea
updated logging in logout. Added before, on login page.
Marcin Kuzminski <marcin@python-works.com>
parents:
195
diff
changeset
|
149 log.info('Logging out and setting user as Empty') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
150 redirect(url('home')) |