Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atharva gauth #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified backend/backend/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified backend/backend/__pycache__/settings.cpython-38.pyc
Binary file not shown.
Binary file added backend/backend/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file added backend/backend/__pycache__/wsgi.cpython-38.pyc
Binary file not shown.
29 changes: 28 additions & 1 deletion backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,36 @@

# Application definition

SITE_ID = 2

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
"user",
"django.contrib.sites",
"allauth",
"allauth.account",
"allauth.socialaccount",
"allauth.socialaccount.providers.google"
]

SOCIALACCOUNT_PROVIDERS = {
"google": {
"SCOPE": [
"profile",
"email"
],
"AUTH_PARAMS": {"access_type": "online"}
}
}

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'allauth.account.middleware.AccountMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand All @@ -54,7 +73,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand Down Expand Up @@ -123,3 +142,11 @@
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend"
)

LOGIN_DIRECT_URL = "/"
LOGOUT_DIRECT_URL = "/"
5 changes: 4 additions & 1 deletion backend/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('allauth.urls')),
path('accounts/', include('allauth.socialaccount.urls')),
path("", include("user.urls")),
]
1 change: 1 addition & 0 deletions backend/client blehh mdgsoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added backend/db.sqlite3
Binary file not shown.
Binary file added backend/user/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file added backend/user/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file added backend/user/__pycache__/apps.cpython-38.pyc
Binary file not shown.
Binary file added backend/user/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file added backend/user/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file added backend/user/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions backend/user/templates/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google Authentication</title>
</head>
<body>
{% load socialaccount %}
<h2>Google Login</h2>
<a href="{% provider_login_url 'google' %}?next=/">LOGIN WITH GOOGLE</a>
</body>
</html>
7 changes: 7 additions & 0 deletions backend/user/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path
from . import views

urlpatterns = [
path("", views.home),
path("logout", views.logout_view),
]
11 changes: 9 additions & 2 deletions backend/user/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from django.shortcuts import render

from django.shortcuts import render, redirect
from django.contrib.auth import logout
# Create your views here.

def home(req):
return render(req, "home.html")

def logout_view(req):
logout(req)
return redirect("/")