Skip to content

Commit bfb00f0

Browse files
authored
Merge pull request #78 from hanlee55/hanlee-dev/account-password-login
feat: Add ID & PW login
2 parents b7387b2 + aa0ed53 commit bfb00f0

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

account/urls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
from .views import GitHubLogin, GoogleLogin, MyPage, mypage_payments
44

5+
from .views import IdLogin, Logout
6+
57
urlpatterns = [
68
path("auth/", include("dj_rest_auth.urls")),
9+
path("account/login/", IdLogin.as_view(), name='account_login'),
10+
path("account/email/", IdLogin.as_view(), name='account_email'),
11+
path("account/logout/", Logout.as_view(), name='account_logout'),
12+
path("account/singup/", IdLogin.as_view(), name="account_signup"),
713
path("auth/github/login/", GitHubLogin.as_view(), name="github_login"),
814
path("auth/google/login/", GoogleLogin.as_view(), name="google_login"),
915
#path("my-page/payments", MyPage.as_view())

account/views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010
import payment
1111

12+
from allauth.account.views import LoginView, LogoutView
13+
14+
class IdLogin(LoginView):
15+
template_name = "account/login.html"
16+
success_url = "/"
17+
18+
class Logout(LogoutView):
19+
template_name = "account/logout.html"
1220

1321
class GitHubLogin(SocialLoginView):
1422
adapter_class = GitHubOAuth2Adapter

templates/account/login.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% load i18n %}
2+
3+
{% block content %}
4+
5+
<h1>{% trans "Sign In" %}</h1>
6+
7+
<form class="login" method="POST" action="{% url 'account_login' %}">
8+
{% csrf_token %}
9+
{{ form.as_p }}
10+
{% if redirect_field_value %}
11+
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
12+
{% endif %}
13+
<button class="primaryAction" type="submit">{% trans "Sign In" %}</button>
14+
</form>
15+
16+
{% endblock %}

templates/account/logout.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% load i18n %}
2+
3+
{% block content %}
4+
<h1>{% trans "Sign Out" %}</h1>
5+
6+
<p>{% trans 'Are you sure you want to sign out?' %}</p>
7+
8+
<form method="post" action="{% url 'account_logout' %}">
9+
{% csrf_token %}
10+
{% if redirect_field_value %}
11+
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/>
12+
{% endif %}
13+
<button type="submit">{% trans 'Sign Out' %}</button>
14+
</form>
15+
16+
17+
{% endblock %}

0 commit comments

Comments
 (0)