Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbbd1cdf

Browse files
committed
Add login with github and prettify account forms
1 parent53370ba commitbbd1cdf

File tree

8 files changed

+239
-73
lines changed

8 files changed

+239
-73
lines changed

‎backend/book/settings.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
'allauth',
4646
'allauth.account',
4747
'allauth.socialaccount',
48+
'allauth.socialaccount.providers.github',
4849
# 'allauth.socialaccount.providers.facebook',
4950
'django_user_agents',
5051
'crispy_forms',
@@ -72,7 +73,7 @@
7273
]
7374

7475
SECURE_PROXY_SSL_HEADER= ('HTTP_X_FORWARDED_PROTO','https')
75-
SECURE_SSL_REDIRECT=True
76+
SECURE_SSL_REDIRECT=notRoot.DEBUG
7677

7778
ROOT_URLCONF='book.urls'
7879

@@ -117,7 +118,7 @@
117118
# Static files (CSS, JavaScript, Images)
118119
# https://docs.djangoproject.com/en/2.2/howto/static-files/
119120

120-
STATIC_URL="/static/"
121+
STATIC_URL="/static_backend/"
121122
STATICFILES_DIRS= [
122123
str(BASE_DIR.parent/f"frontend/build/static")
123124
]
@@ -151,6 +152,12 @@
151152
SITE_ID=1
152153

153154
SOCIALACCOUNT_PROVIDERS= {
155+
'github': {
156+
'APP': {
157+
'client_id':GITHUB_APP.ID,
158+
'secret':GITHUB_APP.SECRET,
159+
}
160+
}
154161
# 'facebook': {
155162
# 'APP': {
156163
# 'client_id': '123',

‎backend/main/simple_settings.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class MONITOR(DryEnv):
3030
SLEEP_TIME=5
3131

3232

33+
classGITHUB_APP(DryEnv):
34+
ID=''
35+
SECRET=''
36+
37+
3338
snoop.install(enabled=Root.DEBUG,out=sys.__stderr__,columns=['thread'])
3439

3540
sentry_sdk.init(

‎backend/main/static/css/main.scss‎

Lines changed: 124 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,126 @@
1-
iframe {
2-
width:100%;
3-
height:100%;
4-
border:none;
5-
}
1+
.signup-form {
2+
width:480px;
3+
margin:0auto;
4+
padding:30px0;
5+
6+
.form-control {
7+
font-size:16px;
8+
transition:all0.4s;
9+
box-shadow:none;
10+
}
11+
12+
.form-control:focus {
13+
border-color:#5cb85c;
14+
}
15+
16+
.form-control,.btn {
17+
border-radius:50px;
18+
outline:none!important;
19+
}
20+
21+
22+
form {
23+
border-radius:5px;
24+
margin-bottom:20px;
25+
background:#fff;
26+
box-shadow:0px2px2pxrgba(0,0,0,0.3);
27+
padding:40px;
28+
}
29+
30+
a {
31+
color:#5cb85c;
32+
}
33+
34+
h2 {
35+
text-align:center;
36+
font-size:34px;
37+
margin:10px015px;
38+
}
39+
40+
.hint-text {
41+
color:#999;
42+
text-align:center;
43+
margin-bottom:20px;
44+
}
45+
46+
.form-group {
47+
margin-bottom:20px;
48+
}
49+
50+
.btn {
51+
font-size:18px;
52+
line-height:26px;
53+
font-weight:bold;
54+
text-align:center;
55+
}
56+
57+
.signup-btn {
58+
text-align:center;
59+
border-color:#5cb85c;
60+
transition:all0.4s;
61+
}
62+
63+
.signup-btn:hover {
64+
background:#5cb85c;
65+
opacity:0.8;
66+
}
67+
68+
.or-seperator {
69+
margin:50px015px;
70+
text-align:center;
71+
border-top:1pxsolid#e0e0e0;
72+
}
73+
74+
.or-seperatorb {
75+
padding:010px;
76+
width:40px;
77+
height:40px;
78+
font-size:16px;
79+
text-align:center;
80+
line-height:40px;
81+
background:#fff;
82+
display:inline-block;
83+
border:1pxsolid#e0e0e0;
84+
border-radius:50%;
85+
position:relative;
86+
top:-22px;
87+
z-index:1;
88+
}
89+
90+
.social-btn.btn {
91+
color:#fff;
92+
margin:10px0015px;
93+
font-size:15px;
94+
border-radius:50px;
95+
font-weight:normal;
96+
border:none;
97+
transition:all0.4s;
98+
}
99+
100+
.social-btn.btn:first-child {
101+
margin-left:0;
102+
}
103+
104+
.social-btn.btn:hover {
105+
opacity:0.8;
106+
}
107+
108+
.social-btn.btn-facebook {
109+
background:#507cc0;
110+
}
111+
112+
.social-btn.btn-github {
113+
background:rgb(51,51,51);
114+
}
115+
116+
.social-btn.btn-google {
117+
background:#df4930;
118+
}
119+
120+
.social-btn.btni {
121+
float:left;
122+
margin:3px10px;
123+
font-size:20px;
124+
}
6125

7-
html,body,.main-layout {
8-
width:100%;
9-
height:100%;
10126
}

‎backend/main/templates/account/login.html‎

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,52 @@
33
{% load i18n %}
44
{% load account socialaccount %}
55

6-
{% block head_title %}{% trans "Sign In" %}{% endblock %}
7-
86
{% block content %}
9-
10-
{% include "messages.html" %}
11-
12-
<h1>{% trans "Sign In" %}</h1>
13-
14-
{% get_providers as socialaccount_providers %}
15-
16-
{% if socialaccount_providers %}
17-
<p>{% blocktrans with site.name as site_name %}Please sign in with one
18-
of your existing third party accounts. Or,<ahref="{{ signup_url }}">sign up</a>
19-
for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
20-
21-
<divclass="socialaccount_ballot">
22-
23-
<ulclass="socialaccount_providers">
24-
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
25-
</ul>
26-
27-
<divclass="login-or">{% trans 'or' %}</div>
28-
29-
</div>
30-
31-
{% include "socialaccount/snippets/login_extra.html" %}
32-
33-
{% else %}
34-
<p>{% blocktrans %}If you have not created an account yet, then please
35-
<ahref="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
36-
{% endif %}
377

38-
<formclass="login"method="POST"action="{% url 'account_login' %}">
39-
{% csrf_token %}
40-
{{ form.as_p }}
41-
{% if redirect_field_value %}
42-
<inputtype="hidden"name="{{ redirect_field_name }}"value="{{ redirect_field_value }}"/>
43-
{% endif %}
44-
{#<aclass="button secondaryAction"href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>#}
45-
<buttonclass="primaryAction"type="submit">{% trans "Sign In" %}</button>
46-
</form>
8+
{% include "messages.html" %}
9+
10+
{% include "socialaccount/snippets/login_extra.html" %}
11+
12+
<style>
13+
body {
14+
background: midnightblue;
15+
}
16+
</style>
17+
18+
<!--suppress HtmlFormInputWithoutLabel -->
19+
<divclass="signup-form">
20+
<formclass="login"method="POST"action="{% url 'account_login' %}">
21+
{% csrf_token %}
22+
{% if redirect_field_value %}
23+
<inputtype="hidden"name="{{ redirect_field_name }}"value="{{ redirect_field_value }}"/>
24+
{% endif %}
25+
26+
<h2>Sign In</h2>
27+
28+
<divclass="social-btn text-center">
29+
<ahref="{% provider_login_url 'github' process='login' %}"class="btn btn-github btn-lg"><i
30+
class="fab fa-github"></i> Connect with GitHub</a>
31+
</div>
32+
<divclass="or-seperator"><b>or</b></div>
33+
34+
{{ form.non_field_errors }}
35+
36+
<divclass="form-group">
37+
<inputtype="email"class="form-control input-lg"name="login"placeholder="Email Address"
38+
required="required">
39+
{{ form.login.errors }}
40+
</div>
41+
<divclass="form-group">
42+
<inputtype="password"class="form-control input-lg"name="password"placeholder="Password"
43+
required="required">
44+
{{ form.password.errors }}
45+
</div>
46+
<divclass="form-group">
47+
<buttontype="submit"class="btn btn-success btn-lg btn-block signup-btn">Sign In</button>
48+
</div>
49+
<divclass="text-center"><ahref="{{ signup_url }}">Need an account?</a></div>
50+
51+
</form>
52+
</div>
4753

4854
{% endblock %}
Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,58 @@
11
{% extends "account/base.html" %}
22

33
{% load i18n %}
4+
{% load account socialaccount %}
45

56
{% block head_title %}{% trans "Signup" %}{% endblock %}
67

78
{% block content %}
8-
<h1>{% trans "Sign Up" %}</h1>
9-
10-
<p>{% blocktrans %}Already have an account? Then please<ahref="{{ login_url }}">sign in</a>.{% endblocktrans %}</p>
11-
12-
<formclass="signup"id="signup_form"method="post"action="{% url 'account_signup' %}">
13-
{% csrf_token %}
14-
{{ form.as_p }}
15-
{% if redirect_field_value %}
16-
<inputtype="hidden"name="{{ redirect_field_name }}"value="{{ redirect_field_value }}"/>
17-
{% endif %}
18-
<buttontype="submit">{% trans "Sign Up" %} &raquo;</button>
19-
</form>
9+
10+
{% include "messages.html" %}
11+
12+
{% include "socialaccount/snippets/login_extra.html" %}
13+
14+
<style>
15+
body {
16+
background: midnightblue;
17+
}
18+
</style>
19+
20+
<!--suppress HtmlFormInputWithoutLabel -->
21+
<divclass="signup-form">
22+
<formclass="login"method="POST"action="{% url 'account_signup' %}">
23+
{% csrf_token %}
24+
{% if redirect_field_value %}
25+
<inputtype="hidden"name="{{ redirect_field_name }}"value="{{ redirect_field_value }}"/>
26+
{% endif %}
27+
28+
<h2>Sign Up</h2>
29+
30+
<p>{% blocktrans %}Already have an account? Then please<ahref="{{ login_url }}">sign in</a>.{% endblocktrans %}
31+
</p>
32+
33+
{{ form.non_field_errors }}
34+
35+
<divclass="form-group">
36+
<inputtype="email"class="form-control input-lg"name="email"placeholder="Email Address"
37+
required="required">
38+
{{ form.email.errors }}
39+
</div>
40+
<divclass="form-group">
41+
<inputtype="password"class="form-control input-lg"name="password1"placeholder="Password"
42+
required="required">
43+
{{ form.password1.errors }}
44+
</div>
45+
<divclass="form-group">
46+
<inputtype="password"class="form-control input-lg"name="password2"placeholder="Password (again)"
47+
required="required">
48+
{{ form.password2.errors }}
49+
</div>
50+
51+
<divclass="form-group">
52+
<buttontype="submit"class="btn btn-success btn-lg btn-block signup-btn">Sign Up</button>
53+
</div>
54+
55+
</form>
56+
</div>
2057

2158
{% endblock %}

‎frontend/src/setupProxy.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const routes = [
66
"/toc",
77
"/birdseye",
88
"/admin",
9+
"/static_backend/",
910
"/api"
1011
];
1112

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp