Skip to content

Commit

Permalink
Merge pull request #2 from Likelion-at-SMWU-10th/feat/#1-social-login
Browse files Browse the repository at this point in the history
Feat/#1 구글 로그인 구현
  • Loading branch information
happine2s authored Jul 15, 2022
2 parents 3416e7a + 6f3e37a commit 0baeb7d
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 21 deletions.
6 changes: 6 additions & 0 deletions rememB/balanceapp/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import path
from . import views

urlpatterns=[

]
2 changes: 0 additions & 2 deletions rememB/letterapp/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.db import models

# Create your models here.
6 changes: 6 additions & 0 deletions rememB/letterapp/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import path
from . import views

urlpatterns=[

]
3 changes: 2 additions & 1 deletion rememB/mainapp/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib import admin
from .models import Blog

# Register your models here.
admin.site.register(Blog)
21 changes: 21 additions & 0 deletions rememB/mainapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.0.6 on 2022-07-15 13:53

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Blog',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.TextField()),
],
),
]
3 changes: 2 additions & 1 deletion rememB/mainapp/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.db import models

# Create your models here.
class Blog(models.Model):
text=models.TextField()
15 changes: 15 additions & 0 deletions rememB/mainapp/templates/mainapp/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% load socialaccount %}
{% providers_media_js %}

<a href="/accounts/signup">회원가입</a>
<br>

{% if user.is_authenticated %}
<a href="/accounts/logout">로그아웃</a>
<br>
{{ user.username }}님이 환영합니다!
{% else %}
<!-- {% csrf_token %} -->
<a href="{% provider_login_url 'google' %}">구글 로그인</a>

{% endif %}
6 changes: 6 additions & 0 deletions rememB/mainapp/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import path
from . import views

urlpatterns=[
path('login/',views.login,name='login'),
]
3 changes: 2 additions & 1 deletion rememB/mainapp/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.shortcuts import render

# Create your views here.
def login(request):
return render(request,'mainapp/login.html')
16 changes: 16 additions & 0 deletions rememB/rememB/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
'mainapp',
'letterapp',
'balanceapp',

#allauth
'allauth',
'allauth.account',
'allauth.socialaccount',

#provider
'allauth.socialaccount.providers.google',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -124,3 +132,11 @@
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

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

SITE_ID=1
LOGIN_REDIRECT_URL='/'
21 changes: 5 additions & 16 deletions rememB/rememB/urls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
"""rememB URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
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('balanceapp/',include('balanceapp.urls')),
path('letterapp/',include('letterapp.urls')),
path('mainapp/',include('mainapp.urls')),
path('accounts/',include('allauth.urls')),
]

0 comments on commit 0baeb7d

Please sign in to comment.