Show More
@@ -42,6 +42,8 class LoginController(BaseController): | |||||
42 |
|
42 | |||
43 | def index(self): |
|
43 | def index(self): | |
44 | #redirect if already logged in |
|
44 | #redirect if already logged in | |
|
45 | c.came_from = request.GET.get('came_from',None) | |||
|
46 | ||||
45 | if c.hg_app_user.is_authenticated: |
|
47 | if c.hg_app_user.is_authenticated: | |
46 | return redirect(url('hg_home')) |
|
48 | return redirect(url('hg_home')) | |
47 |
|
49 | |||
@@ -50,6 +52,9 class LoginController(BaseController): | |||||
50 | login_form = LoginForm() |
|
52 | login_form = LoginForm() | |
51 | try: |
|
53 | try: | |
52 | c.form_result = login_form.to_python(dict(request.POST)) |
|
54 | c.form_result = login_form.to_python(dict(request.POST)) | |
|
55 | if c.came_from: | |||
|
56 | return redirect(c.came_from) | |||
|
57 | else: | |||
53 | return redirect(url('hg_home')) |
|
58 | return redirect(url('hg_home')) | |
54 |
|
59 | |||
55 | except formencode.Invalid as errors: |
|
60 | except formencode.Invalid as errors: |
@@ -228,8 +228,12 class LoginRequired(object): | |||||
228 | return func(*fargs, **fkwargs) |
|
228 | return func(*fargs, **fkwargs) | |
229 | else: |
|
229 | else: | |
230 | log.warn('user %s not authenticated', user.username) |
|
230 | log.warn('user %s not authenticated', user.username) | |
231 | log.debug('redirecting to login page') |
|
231 | ||
232 | return redirect(url('login_home')) |
|
232 | p = request.environ.get('PATH_INFO') | |
|
233 | if request.environ.get('QUERY_STRING'): | |||
|
234 | p+='?'+request.environ.get('QUERY_STRING') | |||
|
235 | log.debug('redirecting to login page with %',p) | |||
|
236 | return redirect(url('login_home',came_from=p)) | |||
233 |
|
237 | |||
234 | class PermsDecorator(object): |
|
238 | class PermsDecorator(object): | |
235 | """Base class for decorators""" |
|
239 | """Base class for decorators""" |
@@ -24,7 +24,7 | |||||
24 | <div class="corner tr"></div> |
|
24 | <div class="corner tr"></div> | |
25 | </div> |
|
25 | </div> | |
26 | <div class="inner"> |
|
26 | <div class="inner"> | |
27 | ${h.form(h.url.current())} |
|
27 | ${h.form(h.url.current(came_from=c.came_from))} | |
28 | <div class="form"> |
|
28 | <div class="form"> | |
29 | <!-- fields --> |
|
29 | <!-- fields --> | |
30 |
|
30 |
General Comments 0
You need to be logged in to leave comments.
Login now