Skip to content

Commit b4da07b

Browse files
committed
Prevent login page for logged-in users
- Insted redirect users to the home page if already logged in Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 8543dcb commit b4da07b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

fedcode/views.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,18 @@ def post(self, request, repository_id):
269269

270270
class UserLogin(LoginView):
271271
template_name = "login.html"
272-
next_page = "/review-list"
272+
next_page = "/"
273+
274+
def dispatch(self, request, *args, **kwargs):
275+
# If user is already logged in, redirect to the next_page.
276+
if request.user.is_authenticated:
277+
return redirect(self.next_page)
278+
return super().dispatch(request, *args, **kwargs)
273279

274280

275281
class PersonSignUp(FormView):
276282
form_class = PersonSignUpForm
277-
success_url = "/review-list"
283+
success_url = "/"
278284
template_name = "user_sign_up.html"
279285

280286
def form_valid(self, form):

0 commit comments

Comments
 (0)