Commit 5dd8e353 authored by Ilham Maulana's avatar Ilham Maulana 💻

fix: frontend auth route

parent d37811a4
...@@ -28,12 +28,6 @@ from rest_framework_simplejwt.views import ( ...@@ -28,12 +28,6 @@ from rest_framework_simplejwt.views import (
) )
from dashboard.views import UpcomingLoanView, OverduedLoanView from dashboard.views import UpcomingLoanView, OverduedLoanView
from users.views import (
LibrarianLoginView,
LibrarianLogoutView,
LibrarianSignUpView,
LibrarianResetPassword,
)
urlpatterns = [ urlpatterns = [
# local # local
...@@ -44,16 +38,7 @@ urlpatterns = [ ...@@ -44,16 +38,7 @@ urlpatterns = [
path("book-loans/", include("loans.urls")), path("book-loans/", include("loans.urls")),
path("upcoming-loans/", UpcomingLoanView.as_view(), name="upcoming_loans"), path("upcoming-loans/", UpcomingLoanView.as_view(), name="upcoming_loans"),
path("overdued-loans/", OverduedLoanView.as_view(), name="overdued_loans"), path("overdued-loans/", OverduedLoanView.as_view(), name="overdued_loans"),
# auth
path("auth/login/", LibrarianLoginView.as_view(), name="librarian_login"),
path("auth/logout/", LibrarianLogoutView.as_view(), name="librarian_logout"),
path("auth/sign-up/", LibrarianSignUpView.as_view(), name="librarian_logout"),
# password reset # password reset
path(
"password-reset/",
LibrarianResetPassword.as_view(),
name="reset_password",
),
path( path(
"password-reset-confirm/<uidb64>/<token>/", "password-reset-confirm/<uidb64>/<token>/",
PasswordResetConfirmView.as_view( PasswordResetConfirmView.as_view(
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
> >
<a <a
class="w-100 btn btn-outline-primary border-white text-white text-start" class="w-100 btn btn-outline-primary border-white text-white text-start"
href="/auth/logout/" href="/users/auth/logout/"
><i class="bi bi-box-arrow-left"></i> logout</a ><i class="bi bi-box-arrow-left"></i> logout</a
> >
</div> </div>
......
...@@ -11,8 +11,8 @@ class AuthMiddleware(MiddlewareMixin): ...@@ -11,8 +11,8 @@ class AuthMiddleware(MiddlewareMixin):
response = self.get_response(request) response = self.get_response(request)
if not request.user.is_authenticated and request.path.startswith("/dashboard/"): if not request.user.is_authenticated and request.path.startswith("/dashboard/"):
return HttpResponseRedirect("/auth/login") return HttpResponseRedirect("/users/auth/login")
elif request.user.is_authenticated and request.path.startswith("/auth/"): elif request.user.is_authenticated and request.path.startswith("/users/auth/"):
return HttpResponseRedirect("/dashboard/") return HttpResponseRedirect("/dashboard/")
else: else:
return response return response
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
<p>{{ error_message }}</p> <p>{{ error_message }}</p>
<div class="d-flex flex-column align-items-center"> <div class="d-flex flex-column align-items-center">
<p class="my-2"> <p class="my-2">
Don't have an account? <a href="/auth/sign-up">Sign Up</a> Don't have an account? <a href="/users/auth/sign-up">Sign Up</a>
</p> </p>
<a href="/password-reset/" class="my-2">Forgot password</a> <a href="/users/password-reset/" class="my-2">Forgot password</a>
</div> </div>
</form> </form>
</main> </main>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</p> </p>
{% endif %} {% endif %}
<p class="my-2"> <p class="my-2">
Already have an account? <a href="/auth/login">Login</a> Already have an account? <a href="/users/auth/login">Login</a>
</p> </p>
</div> </div>
</form> </form>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
> >
Reset Password Reset Password
</button> </button>
<a href="/auth/login/" class="text-center my-2">Back to Login</a> <a href="/users/auth/login/" class="text-center my-2">Back to Login</a>
</form> </form>
</main> </main>
{% endblock content %} {% endblock content %}
\ No newline at end of file
...@@ -10,9 +10,22 @@ from users.views import ( ...@@ -10,9 +10,22 @@ from users.views import (
MemberCreateView, MemberCreateView,
MemberDeleteView, MemberDeleteView,
MemberUpdateView, MemberUpdateView,
LibrarianLoginView,
LibrarianLogoutView,
LibrarianSignUpView,
LibrarianResetPassword,
) )
urlpatterns = [ urlpatterns = [
# auth
path("auth/login/", LibrarianLoginView.as_view(), name="librarian_login"),
path("auth/logout/", LibrarianLogoutView.as_view(), name="librarian_logout"),
path("auth/sign-up/", LibrarianSignUpView.as_view(), name="librarian_logout"),
path(
"password-reset/",
LibrarianResetPassword.as_view(),
name="reset_password",
),
# librarians # librarians
path("librarians/", LibrarianListView.as_view(), name="librarian_lists"), path("librarians/", LibrarianListView.as_view(), name="librarian_lists"),
path("librarians/add/", LibrarianCreateView.as_view(), name="create_librarian"), path("librarians/add/", LibrarianCreateView.as_view(), name="create_librarian"),
......
...@@ -171,7 +171,7 @@ class LibrarianLoginView(LoginView): ...@@ -171,7 +171,7 @@ class LibrarianLoginView(LoginView):
class LibrarianLogoutView(generic.TemplateView): class LibrarianLogoutView(generic.TemplateView):
success_url = "/auth/login/" success_url = "/users/auth/login/"
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs) context = self.get_context_data(**kwargs)
...@@ -186,7 +186,7 @@ class LibrarianLogoutView(generic.TemplateView): ...@@ -186,7 +186,7 @@ class LibrarianLogoutView(generic.TemplateView):
class LibrarianSignUpView(generic.FormView): class LibrarianSignUpView(generic.FormView):
form_class = SignUpForm form_class = SignUpForm
template_name = "librarians/sign_up.html" template_name = "librarians/sign_up.html"
success_url = "/auth/login/" success_url = "/users/auth/login/"
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = self.get_form() form = self.get_form()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment