Update settings and Fix User Activation

Updated some of the values in settings.py and fixed user
activation email template.

Change-Id: I1eb60b624ad5d6516b7750ddbb90dc0d5087e62a
This commit is contained in:
Paarhati Ozkasgarli 2017-03-11 21:04:58 +03:00
parent 4b7320e634
commit 284c955ec6
7 changed files with 18 additions and 19 deletions

View File

@ -8,5 +8,6 @@ urlpatterns = [
url(r'^login/$', auth_views.login, {'template_name': 'authcp/login.html'}, name='login'), url(r'^login/$', auth_views.login, {'template_name': 'authcp/login.html'}, name='login'),
url(r'^logout/$', auth_views.logout, name='logout'), url(r'^logout/$', auth_views.logout, name='logout'),
url(r'^register/$', views.register_user, name='register'), url(r'^register/$', views.register_user, name='register'),
url(r'^register-activate/(?P<key>.+)$', views.activation, name='register-activate'),
url(r'^register-success/$', views.register_success, name='register-success'), url(r'^register-success/$', views.register_success, name='register-success'),
] ]

View File

@ -1,6 +1,7 @@
import random, hashlib, datetime import random, hashlib
from oslo_i18n import translate as _ from oslo_i18n import translate as _
from datetime import timedelta
from django.shortcuts import render, get_object_or_404 from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
@ -45,17 +46,17 @@ def register_user(request):
usernamesalt=form.cleaned_data['email'] usernamesalt=form.cleaned_data['email']
profile=Profile.objects.get(user_id=u.id) profile=Profile.objects.get(user_id=u.id)
profile.activation_key=hashlib.sha1(salt+usernamesalt).hexdigest() profile.activation_key=hashlib.sha1(salt+usernamesalt).hexdigest()
profile.key_expires=datetime.datetime.strftime(datetime.datetime.now() + datetime.timedelta(days=2), profile.key_expires=timezone.now() + timedelta(days=2)
"%Y-%m-%d %H:%M:%S")
profile.save() profile.save()
send_email({'u': u, 'profil': profile}, site_url=settings.SITE_ROOT_URL
send_email({'u': u, 'profile': profile, 'site_url': site_url},
_('Welcome to our cloud'), _('Welcome to our cloud'),
u.email, u.email,
settings.DEFAULT_EMAIL_FROM, settings.DEFAULT_EMAIL_FROM,
) )
return render(request, return render(request,
'authcp/success.html', 'authcp/success.html',
{'u': u, 'profil': profile}) {'u': u, 'profile': profile})
else: else:
print(form.errors) print(form.errors)
else: else:

View File

@ -32,7 +32,7 @@ ALLOWED_HOSTS = [
] ]
# fullt qualified hostname or domain. Ex <http://domain.tld/> # fullt qualified hostname or domain. Ex <http://domain.tld/>
SITE_ROOT_URL = 'http://demo.dash-stack.com/' SITE_ROOT_URL = 'http://127.0.0.1:8000'
# login url # login url
LOGIN_URL = '/auth/login/' LOGIN_URL = '/auth/login/'
@ -116,6 +116,10 @@ DATABASES = {
'PASSWORD': 'password', 'PASSWORD': 'password',
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': '', 'PORT': '',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
'init_command': 'SET innodb_strict_mode=1',
},
} }
} }
@ -140,8 +144,6 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC' TIME_ZONE = 'UTC'
@ -154,8 +156,6 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATICFILES_DIRS = [ STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"), os.path.join(BASE_DIR, "static"),
] ]
@ -169,10 +169,10 @@ STATIC_URL = '/static/'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# Host for sending e-mail. # Host for sending e-mail.
EMAIL_HOST = 'localhost' EMAIL_HOST = '35.156.60.241'
# Port for sending e-mail. # Port for sending e-mail.
EMAIL_PORT = 25 EMAIL_PORT = 587
# Optional SMTP authentication information for EMAIL_HOST. # Optional SMTP authentication information for EMAIL_HOST.
EMAIL_HOST_USER = '' EMAIL_HOST_USER = ''

View File

@ -4,3 +4,4 @@ mysqlclient==1.3.9
oslo.i18n==3.10.0 oslo.i18n==3.10.0
requests==2.12.1 requests==2.12.1
django-settings-export==1.2.1 django-settings-export==1.2.1
pytz==2016.10

View File

@ -7,10 +7,6 @@
<div class="register-logo"> <div class="register-logo">
<a href="/"><b> - </b>stack</a> <a href="/"><b> - </b>stack</a>
</div> </div>
{{ u.get_profile.activation_key }} <br>
{{ profile }}
<div class="login-box-body"> <div class="login-box-body">
<p class="lead"> <p class="lead">
Thank you for registering a new account with us. Thank you for registering a new account with us.

View File

@ -11,7 +11,7 @@
Please click on following link to activate your account: Please click on following link to activate your account:
<p> <p>
<a href="{{ settings.SITE_ROOT_URL }}{{ profile.activation_key }}"> <a href="{{ site_url }}/auth/register-activate/{{ profile.activation_key }}">
{{ profile.activation_key }} {{ profile.activation_key }}
</a> </a>
</p> </p>

View File

@ -2,5 +2,5 @@ Hello,
Welcome to our cloud platform. Welcome to our cloud platform.
Activare your email: Activate your email: