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

Commitfb031ca

Browse files
committed
Add google login
1 parentc24595e commitfb031ca

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

‎backend/book/settings.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
'allauth.account',
4747
'allauth.socialaccount',
4848
'allauth.socialaccount.providers.github',
49+
'allauth.socialaccount.providers.google',
4950
# 'allauth.socialaccount.providers.facebook',
5051
'django_user_agents',
5152
'crispy_forms',
@@ -157,6 +158,15 @@
157158
'client_id':GITHUB_APP.ID,
158159
'secret':GITHUB_APP.SECRET,
159160
}
161+
},
162+
'google': {
163+
'SCOPE': [
164+
'profile',
165+
'email',
166+
],
167+
'AUTH_PARAMS': {
168+
'access_type':'offline',
169+
}
160170
}
161171
# 'facebook': {
162172
# 'APP': {

‎backend/main/management/commands/init_db.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
fromallauth.socialaccount.modelsimportSocialApp
2+
fromdjango.contrib.sites.modelsimportSite
13
fromdjango.core.management.baseimportBaseCommand
24

35
frommain.modelsimportUser
6+
frommain.simple_settingsimportGOOGLE_APP
47

58

69
classCommand(BaseCommand):
@@ -18,3 +21,20 @@ def handle(self, *args, **kwargs):
1821
last_name="Adminson",
1922
email="admin@example.com",
2023
)
24+
25+
print("Modifying site")
26+
site=Site.objects.get()
27+
site.domain="localhost:3000"
28+
site.name="futurecoder"
29+
site.save()
30+
31+
print("Adding Google app")
32+
google_app=SocialApp.objects.create(
33+
provider="google",
34+
name="Google",
35+
client_id=GOOGLE_APP.ID,
36+
secret=GOOGLE_APP.SECRET,
37+
key="",
38+
)
39+
google_app.sites.add(site)
40+
google_app.save()

‎backend/main/simple_settings.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class GITHUB_APP(DryEnv):
3737
SECRET=''
3838

3939

40+
classGOOGLE_APP(DryEnv):
41+
ID=''
42+
SECRET=''
43+
44+
4045
snoop.install(enabled=Root.DEBUG,out=sys.__stderr__,columns=['thread'])
4146

4247
sentry_sdk.init(

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
<h2>Sign In</h2>
2727

2828
<divclass="social-btn text-center">
29+
<ahref="{% provider_login_url 'google' process='login' %}"class="btn btn-google btn-lg"><i
30+
class="fab fa-google"></i> Google</a>
2931
<ahref="{% provider_login_url 'github' process='login' %}"class="btn btn-github btn-lg"><i
30-
class="fab fa-github"></i>Connect withGitHub</a>
32+
class="fab fa-github"></i> GitHub</a>
3133
</div>
3234
<divclass="or-seperator"><b>or</b></div>
3335

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp