From e015b1260ff00e9b77d47ee9b9c1e11b784d6ddb Mon Sep 17 00:00:00 2001 From: Manas Date: Sun, 26 Apr 2020 12:42:09 +0530 Subject: [PATCH 1/2] Github oauth added --- .gitignore | 3 ++- Pipfile | 2 +- Pipfile.lock | 12 ++++++++++-- csqa_project/settings.py | 30 +++++++++++++++--------------- templates/account/signup.html | 32 ++++++++++++++++++++------------ templates/base.html | 1 + 6 files changed, 49 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index ba520cc..deb934f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -db.sqlite3 \ No newline at end of file +db.sqlite3 +migrations diff --git a/Pipfile b/Pipfile index 508dff0..4b2a210 100644 --- a/Pipfile +++ b/Pipfile @@ -16,4 +16,4 @@ djangorestframework = "*" pylint = "*" [requires] -python_version = "3.7" +python_version = "3.6.5" diff --git a/Pipfile.lock b/Pipfile.lock index d001f25..f07ad95 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,11 +1,11 @@ { "_meta": { "hash": { - "sha256": "947485b99926d6ce74b8cd91121c5e8de408364688b2782f0a543c3f4332482a" + "sha256": "8659960929e3b964c12488225aecad385542160fb01d24825858bb7a5dbe46ee" }, "pipfile-spec": 6, "requires": { - "python_version": "3.7" + "python_version": "3.6.5" }, "sources": [ { @@ -175,6 +175,14 @@ ], "version": "==2.3.3" }, + "colorama": { + "hashes": [ + "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff", + "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1" + ], + "markers": "sys_platform == 'win32'", + "version": "==0.4.3" + }, "isort": { "hashes": [ "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", diff --git a/csqa_project/settings.py b/csqa_project/settings.py index bbfdd6c..9fc1083 100644 --- a/csqa_project/settings.py +++ b/csqa_project/settings.py @@ -1,15 +1,3 @@ -""" -Django settings for csqa_project project. - -Generated by 'django-admin startproject' using Django 3.0.5. - -For more information on this file, see -https://docs.djangoproject.com/en/3.0/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.0/ref/settings/ -""" - import sys import dj_database_url import os @@ -51,6 +39,7 @@ 'allauth', 'allauth.account', 'allauth.socialaccount', + 'allauth.socialaccount.providers.github', # for github authentication ( to avoid spam register ) ] MIDDLEWARE = [ @@ -141,7 +130,15 @@ USE_TZ = True - +SOCIALACCOUNT_PROVIDERS = { + 'github': { + 'SCOPE': [ + 'user', + 'repo', + 'read:org', + ], + } +} # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ @@ -160,8 +157,11 @@ "allauth.account.auth_backends.AuthenticationBackend", ) -SITE_ID = 1 +SITE_ID = 2 LOGIN_REDIRECT_URL = '/' -AUTH_USER_MODEL = 'users.User' \ No newline at end of file +AUTH_USER_MODEL = 'users.User' + + + diff --git a/templates/account/signup.html b/templates/account/signup.html index d74c918..c96dda9 100644 --- a/templates/account/signup.html +++ b/templates/account/signup.html @@ -1,17 +1,25 @@ {% extends "account/base.html" %} - +{% load account socialaccount %} {% block content %} -

Sign Up

+
+

Sign Up

+ +
+ +
+
+ Sign up with Github +

Already have an account? Then please sign in.

+
+{% endblock %} -

Already have an account? Then please sign in.

-
- {% csrf_token %} - {{ form.as_p }} - {% if redirect_field_value %} - - {% endif %} - -
+