Skip to content

Commit 7036d8f

Browse files
committed
social authentication with django and vuejs
0 parents  commit 7036d8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1204
-0
lines changed

backend_rest/backend_rest/__init__.py

Whitespace-only changes.
165 Bytes
Binary file not shown.

backend_rest/backend_rest/settings.py

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
"""
2+
Django settings for backend_rest project.
3+
4+
Generated by 'django-admin startproject' using Django 1.11.6.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.11/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/1.11/ref/settings/
11+
"""
12+
13+
import os
14+
15+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = '70(^91ziptt7#9$$zr+4i+&jl300t!3sfo(mtfdc1o@hdkyzdz'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
'rest_framework',
41+
'rest_framework.authtoken',
42+
'rest_auth',
43+
'django.contrib.sites',
44+
'allauth',
45+
'allauth.account',
46+
'rest_auth.registration',
47+
'allauth.socialaccount',
48+
'allauth.socialaccount.providers.facebook',
49+
'corsheaders',
50+
]
51+
52+
SITE_ID = 3
53+
54+
MIDDLEWARE = [
55+
'django.middleware.security.SecurityMiddleware',
56+
'django.contrib.sessions.middleware.SessionMiddleware',
57+
'django.middleware.common.CommonMiddleware',
58+
'django.middleware.csrf.CsrfViewMiddleware',
59+
'django.contrib.auth.middleware.AuthenticationMiddleware',
60+
'django.contrib.messages.middleware.MessageMiddleware',
61+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
62+
'corsheaders.middleware.CorsMiddleware',
63+
'django.middleware.common.CommonMiddleware',
64+
]
65+
66+
ROOT_URLCONF = 'backend_rest.urls'
67+
68+
TEMPLATES = [
69+
{
70+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
71+
'DIRS': [],
72+
'APP_DIRS': True,
73+
'OPTIONS': {
74+
'context_processors': [
75+
'django.template.context_processors.debug',
76+
'django.template.context_processors.request',
77+
'django.contrib.auth.context_processors.auth',
78+
'django.contrib.messages.context_processors.messages',
79+
],
80+
},
81+
},
82+
]
83+
84+
WSGI_APPLICATION = 'backend_rest.wsgi.application'
85+
86+
87+
# Database
88+
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
89+
90+
DATABASES = {
91+
'default': {
92+
'ENGINE': 'django.db.backends.sqlite3',
93+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
94+
}
95+
}
96+
97+
98+
# Password validation
99+
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
100+
101+
AUTH_PASSWORD_VALIDATORS = [
102+
{
103+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
104+
},
105+
{
106+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
107+
},
108+
{
109+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
110+
},
111+
{
112+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
113+
},
114+
]
115+
116+
117+
# Internationalization
118+
# https://docs.djangoproject.com/en/1.11/topics/i18n/
119+
120+
LANGUAGE_CODE = 'en-us'
121+
122+
TIME_ZONE = 'UTC'
123+
124+
USE_I18N = True
125+
126+
USE_L10N = True
127+
128+
USE_TZ = True
129+
130+
131+
# Static files (CSS, JavaScript, Images)
132+
# https://docs.djangoproject.com/en/1.11/howto/static-files/
133+
134+
STATIC_URL = '/static/'
135+
136+
CORS_ORIGIN_WHITELIST = (
137+
'localhost:8080',
138+
'127.0.0.1:8080'
139+
)
140+
141+
SOCIALACCOUNT_EMAIL_VERIFICATION = 'none'
142+
SOCIALACCOUNT_EMAIL_REQUIRED = False
143+
SOCIALACCOUNT_QUERY_EMAIL = True
3.16 KB
Binary file not shown.

backend_rest/backend_rest/urls.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""backend_rest URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/1.11/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.conf.urls import url, include
14+
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
15+
"""
16+
from django.conf.urls import url, include
17+
from django.contrib import admin
18+
from . import views
19+
20+
urlpatterns = [
21+
url(r'^admin/', admin.site.urls),
22+
url(r'^auth/', include('rest_auth.urls')),
23+
url(r'^auth/facebook/$', views.FacebookLogin.as_view(), name='fb_login'),
24+
]

backend_rest/backend_rest/urls.pyc

1.21 KB
Binary file not shown.

backend_rest/backend_rest/views.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter
2+
from rest_auth.registration.views import SocialLoginView
3+
4+
class FacebookLogin(SocialLoginView):
5+
adapter_class = FacebookOAuth2Adapter

backend_rest/backend_rest/views.pyc

606 Bytes
Binary file not shown.

backend_rest/backend_rest/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for backend_rest project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend_rest.settings")
15+
16+
application = get_wsgi_application()

backend_rest/backend_rest/wsgi.pyc

633 Bytes
Binary file not shown.

backend_rest/db.sqlite3

256 KB
Binary file not shown.

backend_rest/manage.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend_rest.settings")
7+
try:
8+
from django.core.management import execute_from_command_line
9+
except ImportError:
10+
# The above import may fail for some other reason. Ensure that the
11+
# issue is really that Django is missing to avoid masking other
12+
# exceptions on Python 2.
13+
try:
14+
import django
15+
except ImportError:
16+
raise ImportError(
17+
"Couldn't import Django. Are you sure it's installed and "
18+
"available on your PYTHONPATH environment variable? Did you "
19+
"forget to activate a virtual environment?"
20+
)
21+
raise
22+
execute_from_command_line(sys.argv)

social_auth/.babelrc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"modules": false,
5+
"targets": {
6+
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7+
}
8+
}],
9+
"stage-2"
10+
],
11+
"plugins": ["transform-runtime"],
12+
"env": {
13+
"test": {
14+
"presets": ["env", "stage-2"],
15+
"plugins": ["istanbul"]
16+
}
17+
}
18+
}

social_auth/.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

social_auth/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Editor directories and files
9+
.idea
10+
.vscode
11+
*.suo
12+
*.ntvs*
13+
*.njsproj
14+
*.sln

social_auth/.postcssrc.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// https://github.com/michael-ciniawsky/postcss-load-config
2+
3+
module.exports = {
4+
"plugins": {
5+
// to edit target browsers: use "browserslist" field in package.json
6+
"autoprefixer": {}
7+
}
8+
}

social_auth/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# social_auth
2+
3+
> A Vue.js project
4+
5+
## Build Setup
6+
7+
``` bash
8+
# install dependencies
9+
npm install
10+
11+
# serve with hot reload at localhost:8080
12+
npm run dev
13+
14+
# build for production with minification
15+
npm run build
16+
17+
# build for production and view the bundle analyzer report
18+
npm run build --report
19+
```
20+
21+
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

social_auth/build/build.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict'
2+
require('./check-versions')()
3+
4+
process.env.NODE_ENV = 'production'
5+
6+
const ora = require('ora')
7+
const rm = require('rimraf')
8+
const path = require('path')
9+
const chalk = require('chalk')
10+
const webpack = require('webpack')
11+
const config = require('../config')
12+
const webpackConfig = require('./webpack.prod.conf')
13+
14+
const spinner = ora('building for production...')
15+
spinner.start()
16+
17+
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18+
if (err) throw err
19+
webpack(webpackConfig, function (err, stats) {
20+
spinner.stop()
21+
if (err) throw err
22+
process.stdout.write(stats.toString({
23+
colors: true,
24+
modules: false,
25+
children: false,
26+
chunks: false,
27+
chunkModules: false
28+
}) + '\n\n')
29+
30+
if (stats.hasErrors()) {
31+
console.log(chalk.red(' Build failed with errors.\n'))
32+
process.exit(1)
33+
}
34+
35+
console.log(chalk.cyan(' Build complete.\n'))
36+
console.log(chalk.yellow(
37+
' Tip: built files are meant to be served over an HTTP server.\n' +
38+
' Opening index.html over file:// won\'t work.\n'
39+
))
40+
})
41+
})

social_auth/build/check-versions.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict'
2+
const chalk = require('chalk')
3+
const semver = require('semver')
4+
const packageConfig = require('../package.json')
5+
const shell = require('shelljs')
6+
function exec (cmd) {
7+
return require('child_process').execSync(cmd).toString().trim()
8+
}
9+
10+
const versionRequirements = [
11+
{
12+
name: 'node',
13+
currentVersion: semver.clean(process.version),
14+
versionRequirement: packageConfig.engines.node
15+
}
16+
]
17+
18+
if (shell.which('npm')) {
19+
versionRequirements.push({
20+
name: 'npm',
21+
currentVersion: exec('npm --version'),
22+
versionRequirement: packageConfig.engines.npm
23+
})
24+
}
25+
26+
module.exports = function () {
27+
const warnings = []
28+
for (let i = 0; i < versionRequirements.length; i++) {
29+
const mod = versionRequirements[i]
30+
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
31+
warnings.push(mod.name + ': ' +
32+
chalk.red(mod.currentVersion) + ' should be ' +
33+
chalk.green(mod.versionRequirement)
34+
)
35+
}
36+
}
37+
38+
if (warnings.length) {
39+
console.log('')
40+
console.log(chalk.yellow('To use this template, you must update following to modules:'))
41+
console.log()
42+
for (let i = 0; i < warnings.length; i++) {
43+
const warning = warnings[i]
44+
console.log(' ' + warning)
45+
}
46+
console.log()
47+
process.exit(1)
48+
}
49+
}

social_auth/build/dev-client.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-disable */
2+
'use strict'
3+
require('eventsource-polyfill')
4+
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
5+
6+
hotClient.subscribe(function (event) {
7+
if (event.action === 'reload') {
8+
window.location.reload()
9+
}
10+
})

0 commit comments

Comments
 (0)