Skip to content

Commit

Permalink
Added Social Signup/Login
Browse files Browse the repository at this point in the history
  • Loading branch information
yatna committed Jul 3, 2017
1 parent a09ab54 commit cd983d1
Show file tree
Hide file tree
Showing 17 changed files with 585 additions and 10 deletions.
8 changes: 8 additions & 0 deletions infohub/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SOCIAL_AUTH_TWITTER_KEY = 'AjLIz913Xk5gXFEx7ErAyHFrJ'
SOCIAL_AUTH_TWITTER_SECRET = '50Hyxds06GZIT3JEfh5KEQXavphbH9gYdSbH0UO8tTg9eMLMyv'

SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '856425658206-uulba4lm3oe2lc1pldl72aoh1lb20fdt.apps.googleusercontent.com'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'FRf74dTfIG620ESyq_LvYhWU'

SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/home/'
SOCIAL_AUTH_LOGIN_URL = '/'
21 changes: 18 additions & 3 deletions infohub/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from infohub.config import *

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

Expand Down Expand Up @@ -26,6 +27,9 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',

'social_django.context_processors.backends', # <--
'social_django.context_processors.login_redirect', # <--
],
},

Expand All @@ -52,7 +56,8 @@
'profiles',
'pcsa',
'pcsa_GHN',
'pcsa_safety_tools'
'pcsa_safety_tools',
'social_django'
)

MIDDLEWARE_CLASSES = (
Expand All @@ -62,6 +67,16 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
)

AUTHENTICATION_BACKENDS = (
'social_core.backends.github.GithubOAuth2',
'social_core.backends.twitter.TwitterOAuth',
'social_core.backends.facebook.FacebookOAuth2',
'social_core.backends.google.GoogleOAuth2',

'django.contrib.auth.backends.ModelBackend',
)

ROOT_URLCONF = 'infohub.urls'
Expand All @@ -75,8 +90,8 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'webapp',
'USER': 'myuser',
'NAME': 'webapp3',
'USER': 'myuser2',
'PASSWORD': 'mypassword',
'HOST': 'localhost',
}
Expand Down
3 changes: 2 additions & 1 deletion infohub/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
# url(r'^profiles/', include('profiles.urls', namespace='profiles')),
url(r'^pcsa/', include('pcsa.urls', namespace='pcsa')),
url(r'^gethelpnow/', include('pcsa_GHN.urls', namespace='pcsa_GHN')),
url(r'^safetytools/', include('pcsa_safety_tools.urls', namespace='pcsa_safety_tools'))
url(r'^safetytools/', include('pcsa_safety_tools.urls', namespace='pcsa_safety_tools')),
url('', include('social_django.urls', namespace='social')),
]
4 changes: 2 additions & 2 deletions profiles/templates/profiles/profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
.content ol{
text-align: left;
margin-left: 40px;
margin-bottom: 40px;
margin-bottom: 0px;
}
.content li{
padding: 0 10px;
line-height: 40px;
line-height: 35px;
}
.content span{

Expand Down
1 change: 1 addition & 0 deletions profiles/templates/profiles/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<h3><b>User Profile</b></h3>

<ol>
<li><span><font color="black"> User Name </span>: </font>{{profiler.user.username}}</li>
<li><span><font color="black"> First Name </span>: </font>{{profiler.user.first_name}}</li>
<li><span><font color="black">Last Name </span>: </font>{{profiler.user.last_name}}</li>
<li><span><font color="black">Email Address </span>: </font>{{profiler.user.email}}</li>
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Pillow==4.1.1
psycopg2==2.7.1
PyYAML==3.12
static3==0.7.0
social-auth-app-django
autoenv
19 changes: 17 additions & 2 deletions signup/templates/signup/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,29 @@ <h2>Sign Up</h2>

<br><br>
<input class="btn btn-default" type="submit" name="submit" value="Submit"><br><br>
<input type="hidden" name="fname" value="bhanu">
<input type="hidden" name="lname" value="teja">

</form>
<br><br>
{% if user and not user.is_anonymous %}
<h1>hg</h1>

{% else %}
<h1> gd</h1>

{% endif %}

<br><br>


</div>

</center>

<br><br>




{% include "malaria/footer.html" %}


Expand Down
4 changes: 2 additions & 2 deletions signup/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def signup_do(request):
if password != confirmpassword:
return HttpResponse(jinja_environ.get_template('signup.html').render({"pcuser":None, "text":'<p>Passwords don\'t match. Please Enter again.</p>'}))

first_name = "" ""
last_name = "" ""
first_name = request.POST['fname']
last_name = request.POST['lname']
phone = request.POST['phone']
email = request.POST['email']
gender = request.POST['gender']
Expand Down
147 changes: 147 additions & 0 deletions templates/bootstrap-social.css

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions templates/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<style>
{% include "style.css" %}
{% include "sticky-footer.css" %}
</style>
<section class="footer">
<div class="">
<nav>
<ul>
<li><a href="/aboutPC" title="Home" >About Peace Corps</a> </li>
<li><a href="/policies/" title="Know about our team" >Policies </a></li>
<li><a href="/details/" title="FAQs">Important Details</a></li>
<li><a href="/helpPC/" title="Contact Us">Help</a></li>
</ul>
<nav>
<p>&copy 2017 PeaceCorps</p>
</div>
</section>
16 changes: 16 additions & 0 deletions templates/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<style>
{% include "style.css" %}
</style>


<section class="header" id="top">
<div class="container">
<div class="logo"><a href="/"><img src="http://i.imgur.com/KKTKQJv.png?1" class="img-responsive"></a></div>
<div class="macc">
<a href="/" >
<h1> Mobile App Control Center</h1>
</a>

</div>
</div>
</section>
55 changes: 55 additions & 0 deletions templates/login_real.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script src="https://use.fontawesome.com/a92a526874.js"></script>

<style>
{% include "bootstrap-social.css" %}
</style>
</head>
<body>

{% include "header.html" %}
<br><br><br>

{% if user and not user.is_anonymous %}
<h1>{{user.username}} ! {{user.first_name}}, {{user.last_name}}, {{user.email}}</h1>
<form action="/login_social/" method="POST" id="myprofile">
{% csrf_token %}
<input type="hidden" name="uname" value="{{user.username}}">
<input type="hidden" name="fname" value="{{user.first_name}}">
<input type="hidden" name="lname" value="{{user.last_name}}">
<input type="hidden" name="email" value="{{user.email}}">
{% csrf_token %}
<script type="text/javascript">
document.getElementById('myprofile').submit();
</script>
</form>
<p><a href="/logout_do/">Logout</a>

{% else %}
<center>
<br><br><br><br><br><br><br><br>
<a href="{% url 'social:begin' 'twitter' %}?next={{request.path }}" class="btn btn-social btn-twitter"><span class="fa fa-twitter"></span>Login with Twitter</a>
<a href="{% url 'social:begin' 'google-oauth2' %}?next={{ request.path }}" class="btn btn-social btn-google"> <span class="fa fa-google"></span>Login with Google</a>
</center>

{% endif %}

<br><br>
{% include "footer.html" %}



</body>

</html>

37 changes: 37 additions & 0 deletions templates/sticky-footer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}

body {
/* Margin bottom by footer height */
margin-bottom: 150px;
}

.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
/* Set margin-bottom of body to this value as well */
min-height: 110px;
background-color: #DCDCDC;
text-align: center;
padding: 15px;
}

.footer-content {
padding-top: 35px;
}

.footer-mid-text {
color: #2c0f00;
display: inline;
}

.footer-small-text {
color: #2c0f00;
padding-top: 20px;
}
Loading

0 comments on commit cd983d1

Please sign in to comment.