Skip to content

Commit bc4c5f4

Browse files
author
shubhangi-bhandari-epam
committed
Fix Github and Google Login/Signup
1 parent d7de25b commit bc4c5f4

4 files changed

Lines changed: 53 additions & 19 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,4 @@ qr_files/
9191
.vscode/
9292

9393
tmp/
94+
sign_in_steps.txt

junction/templates/account/login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% load i18n %}
33
{% load account %}
44
{% load django_bootstrap_breadcrumbs %}
5-
{% load account socialaccount %}
5+
{% load socialaccount %}
66

77
{% block head_title %}{% trans "Sign In" %} · {{ block.super }}{% endblock %}
88

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ qrcode==7.3.1
4949

5050
#server
5151
#uwsgi
52+
53+
# ssl certificate
54+
django-sslserver

settings/common.py

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
"django.contrib.sessions",
5757
"django.contrib.messages",
5858
"django.contrib.staticfiles",
59-
# "django.contrib.sites",
59+
"django.contrib.sites",
6060
)
61-
61+
6262
THIRD_PARTY_APPS = (
6363
"allauth",
6464
"allauth.account",
@@ -72,6 +72,7 @@
7272
"rest_framework",
7373
"django_filters",
7474
"simple_history",
75+
#"sslserver", used in development server only
7576
)
7677

7778
OUR_APPS = (
@@ -86,6 +87,36 @@
8687
)
8788

8889
INSTALLED_APPS = CORE_APPS + THIRD_PARTY_APPS + OUR_APPS
90+
SITE_ID = 1
91+
92+
# Provider specific settings
93+
SOCIALACCOUNT_PROVIDERS = {
94+
'github': {
95+
# For each provider, you can choose whether or not the
96+
# email address(es) retrieved from the provider are to be
97+
# interpreted as verified.
98+
'VERIFIED_EMAIL': True,
99+
'APP': {
100+
'client_id': 'enter your github client_id',
101+
'secret': 'enter your github secret key',
102+
'key': '',
103+
},
104+
},
105+
'google': {
106+
# For each OAuth based provider, either add a ``SocialApp``
107+
# (``socialaccount`` app) containing the required client
108+
# credentials, or list them here:
109+
'SCOPE': {
110+
'profile',
111+
'email',
112+
},
113+
'APP': {
114+
'client_id': 'enter your google client_id',
115+
'secret': 'enter your google secret key',
116+
'key': '',
117+
},
118+
}
119+
}
89120

90121

91122
TEMPLATES = [
@@ -119,19 +150,18 @@
119150
ACCOUNT_EMAIL_SUBJECT_PREFIX = "[{}] ".format(SITE_VARIABLES["site_name"])
120151
ACCOUNT_LOGOUT_ON_GET = True
121152
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
122-
123153
EMAIL_SUBJECT_PREFIX = ACCOUNT_EMAIL_SUBJECT_PREFIX
124154

125155
LOGIN_REDIRECT_URL = "/"
126156

127157
# E-Mail Settings
128158
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
129-
EMAIL_HOST = "smtp.sendgrid.com"
130-
EMAIL_HOST_USER = (os.environ.get("EMAIL_HOST_USER", ""),)
131-
EMAIL_HOST_PASSWORD = (os.environ.get("EMAIL_HOST_PASSWORD", ""),)
159+
EMAIL_HOST = "smtp.gmail.com"
160+
EMAIL_HOST_USER = DEFAULT_FROM_EMAIL = (os.environ.get("EMAIL_HOST_USER", "enter gmail id"),)
161+
EMAIL_HOST_PASSWORD = (os.environ.get("EMAIL_HOST_PASSWORD", "enter App password"),) #turn on 2-step verification in your gmail account and add App password
132162
EMAIL_PORT = 587
133163
EMAIL_USE_TLS = True
134-
DEFAULT_FROM_EMAIL = SITE_VARIABLES["site_name"] + " <noreply@pssi.org.in>"
164+
# DEFAULT_FROM_EMAIL = SITE_VARIABLES["site_name"] + " <noreply@pssi.org.in>"
135165

136166
BOOTSTRAP3 = {
137167
"required_css_class": "required",
@@ -186,26 +216,26 @@
186216

187217

188218
DATABASES = {
219+
"default": {
220+
"ENGINE": "django.db.backends.postgresql_psycopg2",
221+
"NAME": os.environ.get("DB_NAME", "enter postgres db name"),
222+
"USER": os.environ.get("DB_USER", "postgres"),
223+
"PASSWORD": os.environ.get("DB_PASSWORD", "enter postgres password"),
224+
"HOST": os.environ.get("DB_HOST", "localhost"),
225+
"PORT": os.environ.get("DB_PORT", "5432"),
226+
}
189227
# "default": {
190-
# "ENGINE": "django.db.backends.postgresql_psycopg2",
191-
# "NAME": os.environ.get("DB_NAME", ""),
192-
# "USER": os.environ.get("DB_USER", ""),
193-
# "PASSWORD": os.environ.get("DB_PASSWORD", ""),
194-
# "HOST": os.environ.get("DB_HOST", ""),
195-
# "PORT": os.environ.get("DB_PORT", ""),
228+
# "ENGINE": "django.db.backends.sqlite3",
229+
# "NAME": os.path.join(ROOT_DIR, "test.sqlite3"),
196230
# }
197-
"default": {
198-
"ENGINE": "django.db.backends.sqlite3",
199-
"NAME": os.path.join(ROOT_DIR, "test.sqlite3"),
200-
}
201231
}
202232

203233
SECRET_KEY = os.environ.get(
204234
"SECRET_KEY", "z^bd9lk)o!03n#9e_u87zidd1zt7*^_oc4v6t!@@86vtbu0*&j"
205235
)
206236

207237

208-
ALLOWED_HOSTS = ["*"]
238+
ALLOWED_HOSTS = ["*"]
209239

210240
SITE_PROTOCOL = "http"
211241

0 commit comments

Comments
 (0)