Skip to content

Commit

Permalink
Merge pull request #173 from ankita685/main
Browse files Browse the repository at this point in the history
added google authentication fixes #74 #154
  • Loading branch information
anurag6569201 authored Jul 16, 2024
2 parents 9070c23 + 0c259c3 commit b9aa5c8
Show file tree
Hide file tree
Showing 8,919 changed files with 1,149,645 additions and 5 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file not shown.
Binary file not shown.
Binary file added newsaggregator/core/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified newsaggregator/db.sqlite3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions newsaggregator/newsaggregator/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

# custom apps
'django_social_share',
'social_django',

'core',

# authentication
Expand All @@ -62,6 +64,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',

# render.com middleware
"whitenoise.middleware.WhiteNoiseMiddleware",
Expand All @@ -80,6 +83,7 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'social_django.context_processors.backends',
],
},
},
Expand Down Expand Up @@ -147,3 +151,16 @@
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

AUTH_USER_MODEL='userauths.User'


AUTHENTICATION_BACKENDS =[
'social_core.backends.google.GoogleOAuth2',
'django.contrib.auth.backends.ModelBackend',
]
LOGIN_URL = 'login'
LOGIN_REDIRECT_URL = 'home'
LOGOUT_URL ='logout'
LOGOUT_REDIRECT_URL ='login'

SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = 'google_key'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET ='google_secret'
7 changes: 7 additions & 0 deletions newsaggregator/newsaggregator/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from django.contrib import admin
from django.urls import path, include
from django.contrib.auth import views as auth_views
from userauths import views

urlpatterns = [
path('admin/', admin.site.urls),
path('user/',include('userauths.urls')),
path('',include('core.urls')),
path('login/',views.login, name ='login'),
path('logout/',auth_views.LogoutView.as_view(),name ='logout'),
path('social-auth/',include('social_django.urls',namespace='social')),
path("",views.home,name='home'),


]
1 change: 1 addition & 0 deletions newsaggregator/static/assets/css/userauth.css
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ body {
border-radius: 4px;
}


button:disabled {
background-color: rgba(0, 149, 246, 0.3);
}
Expand Down
42 changes: 40 additions & 2 deletions newsaggregator/templates/userauths/sign-in.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@
{% load static %}

{% block authentication %}
<style>
.social-container1 {
text-align: center; /* Center-align content */
}

.btn-primary1 {
background-color: #4285F4; /* Google Blue */
border: none; /* Remove border */
padding: 10px 20px; /* Adjust padding */
font-size: 16px; /* Adjust font size */
cursor: pointer; /* Add cursor pointer on hover */
}

.btn-primary1:hover {
background-color: #357AE8; /* Darker shade of Google Blue on hover */
}

.btn-lin {
color: #fff; /* White text color */
text-decoration: none; /* Remove underline */
}

.btn-lin:hover {
color: #fff; /* White text color on hover */
text-decoration: none; /* Remove underline on hover */
}
</style>

<div class="container">
<div class="main-container">
<div class="main-content">
Expand Down Expand Up @@ -59,8 +87,18 @@
</div>
</div>
</form>



<div class="row">
<div class="col-md-8 mx-auto my-2 order-md-1">
<div class="social-container1">
<button class="btn btn-primary1 mb-4">
<a href="{% url 'social:begin' 'google-oauth2' %}" class="btn-lin">Login With Google</a>
</button>
</div>
</div>
</div>


</div>
<div class="box goto">
<p>
Expand Down
38 changes: 37 additions & 1 deletion newsaggregator/templates/userauths/sign-up.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@
{% load static %}

{% block authentication %}

<style>
.social-container1 {
text-align: center; /* Center-align content */
}

.btn-primary1 {
background-color: #4285F4; /* Google Blue */
border: none; /* Remove border */
padding: 10px 20px; /* Adjust padding */
font-size: 16px; /* Adjust font size */
cursor: pointer; /* Add cursor pointer on hover */
}

.btn-primary1:hover {
background-color: #357AE8; /* Darker shade of Google Blue on hover */
}

.btn-lin {
color: #fff; /* White text color */
text-decoration: none; /* Remove underline */
}

.btn-lin:hover {
color: #fff; /* White text color on hover */
text-decoration: none; /* Remove underline on hover */
}
</style>
<div class="container">
<div class="main-container">
<div class="main-content">
Expand Down Expand Up @@ -85,7 +113,15 @@

</div>
</form>

<div class="row">
<div class="col-md-8 mx-auto my-2 order-md-1">
<div class="social-container1">
<button class="btn btn-primary1 mb-4">
<a href="{% url 'social:begin' 'google-oauth2' %}" class="btn-lin">Login With Google</a>
</button>
</div>
</div>
</div>

</div>
<div class="box goto">
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion newsaggregator/userauths/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.urls import path
from django.contrib import admin
from django.urls import path, include
from django.contrib.auth import views as auth_views
from userauths import views

app_name='userauths'
Expand Down
5 changes: 4 additions & 1 deletion newsaggregator/userauths/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ def logout_view(request):
logout(request)
messages.success(request, "You Logged-Out, successfully")

return redirect("userauths:sign-in",)
return redirect("userauths:sign-in",)

def home(request):
return render(request,'base_auth.html')
Loading

0 comments on commit b9aa5c8

Please sign in to comment.