Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
library-app-django
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ilham Maulana
library-app-django
Commits
5dd8e353
Commit
5dd8e353
authored
Jul 21, 2024
by
Ilham Maulana
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: frontend auth route
parent
d37811a4
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
22 additions
and
24 deletions
+22
-24
urls.py
config/urls.py
+0
-15
profile.html
dashboard/templates/profile.html
+1
-1
middleware.py
users/middleware.py
+2
-2
login.html
users/templates/librarians/login.html
+2
-2
sign_up.html
users/templates/librarians/sign_up.html
+1
-1
password_reset.html
users/templates/password/password_reset.html
+1
-1
urls.py
users/urls.py
+13
-0
views.py
users/views.py
+2
-2
No files found.
config/urls.py
View file @
5dd8e353
...
@@ -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
(
...
...
dashboard/templates/profile.html
View file @
5dd8e353
...
@@ -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>
...
...
users/middleware.py
View file @
5dd8e353
...
@@ -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
users/templates/librarians/login.html
View file @
5dd8e353
...
@@ -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>
...
...
users/templates/librarians/sign_up.html
View file @
5dd8e353
...
@@ -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>
...
...
users/templates/password/password_reset.html
View file @
5dd8e353
...
@@ -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
users/urls.py
View file @
5dd8e353
...
@@ -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"
),
...
...
users/views.py
View file @
5dd8e353
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment