Show More
@@ -74,22 +74,19 b' class LoginController(BaseController):' | |||||
74 | return False |
|
74 | return False | |
75 | return True |
|
75 | return True | |
76 |
|
76 | |||
77 | def _redirect_to_origin(self, origin): |
|
|||
78 | '''redirect to the original page, preserving any get arguments given''' |
|
|||
79 | request.GET.pop('came_from', None) |
|
|||
80 | raise HTTPFound(location=url(origin, **request.GET)) |
|
|||
81 |
|
||||
82 | def index(self): |
|
77 | def index(self): | |
83 |
c.came_from = safe_str(request.GET. |
|
78 | c.came_from = safe_str(request.GET.pop('came_from', '')) | |
84 |
if |
|
79 | if self._validate_came_from(c.came_from): | |
85 |
|
|
80 | came_from = url(c.came_from, **request.GET) | |
|
81 | else: | |||
|
82 | c.came_from = came_from = url('home') | |||
86 |
|
83 | |||
87 | not_default = self.authuser.username != User.DEFAULT_USER |
|
84 | not_default = self.authuser.username != User.DEFAULT_USER | |
88 | ip_allowed = AuthUser.check_ip_allowed(self.authuser, self.ip_addr) |
|
85 | ip_allowed = AuthUser.check_ip_allowed(self.authuser, self.ip_addr) | |
89 |
|
86 | |||
90 | # redirect if already logged in |
|
87 | # redirect if already logged in | |
91 | if self.authuser.is_authenticated and not_default and ip_allowed: |
|
88 | if self.authuser.is_authenticated and not_default and ip_allowed: | |
92 | return self._redirect_to_origin(c.came_from) |
|
89 | raise HTTPFound(location=came_from) | |
93 |
|
90 | |||
94 | if request.POST: |
|
91 | if request.POST: | |
95 | # import Login Form validator class |
|
92 | # import Login Form validator class | |
@@ -119,7 +116,7 b' class LoginController(BaseController):' | |||||
119 | else: |
|
116 | else: | |
120 | log_in_user(user, c.form_result['remember'], |
|
117 | log_in_user(user, c.form_result['remember'], | |
121 | is_external_auth=False) |
|
118 | is_external_auth=False) | |
122 | return self._redirect_to_origin(c.came_from) |
|
119 | raise HTTPFound(location=came_from) | |
123 |
|
120 | |||
124 | return render('/login.html') |
|
121 | return render('/login.html') | |
125 |
|
122 |
@@ -16,7 +16,7 b'' | |||||
16 | %endif |
|
16 | %endif | |
17 | </div> |
|
17 | </div> | |
18 | <div class="panel-body inner"> |
|
18 | <div class="panel-body inner"> | |
19 | ${h.form(h.url.current(**request.GET))} |
|
19 | ${h.form(h.url.current(came_from=c.came_from, **request.GET))} | |
20 | <div class="form"> |
|
20 | <div class="form"> | |
21 | <i class="icon-lock"></i> |
|
21 | <i class="icon-lock"></i> | |
22 | <!-- fields --> |
|
22 | <!-- fields --> |
General Comments 0
You need to be logged in to leave comments.
Login now