Merge pull request #324 from pcoder/feature/3296/confirm_emails

Feature/3296/confirm emails
This commit is contained in:
Levi Velázquez 2017-06-15 15:22:00 -05:00 committed by GitHub
commit 5271591cf3
8 changed files with 348 additions and 14 deletions

View file

@ -24,6 +24,8 @@ class HostingUserLoginForm(forms.Form):
is_auth = authenticate(email=email, password=password)
if not is_auth:
raise forms.ValidationError("Your username and/or password were incorrect.")
elif is_auth.validated == 0:
raise forms.ValidationError(_("Your account is not activated yet."))
return self.cleaned_data
def clean_email(self):

View file

@ -318,6 +318,17 @@ h6 {
padding: 15px 20px 0 20px;
}
.sign-up-message {
padding: 25px 30px 25px 30px;
text-align: justify;
font-size: 18px;
line-height: 30px;
}
.sign-up-message a {
font-size: 18px;
color: #1e94cc !important;
}
@media (max-width: 1199px) {
ul.banner-social-buttons {
float: left;

View file

@ -0,0 +1,21 @@
{% extends "hosting/base_short.html" %}
{% load staticfiles bootstrap3 i18n %}
{% block content %}
<div class="auth-container">
<div class="auth-bg"></div>
<div class="container">
<div class="auth-title">
<h2>{% trans "Your VM hosted in Switzerland"%}</h2>
</div>
<div class="auth-content">
<div class="intro-message auth-box sign-up">
<h2 class="section-heading">{{section_title}}</h2>
<div class="sign-up-message">
{{message}}
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -1,7 +1,7 @@
from django.conf.urls import url
from .views import DjangoHostingView, RailsHostingView, PaymentVMView,\
NodeJSHostingView, LoginView, SignupView, IndexView, \
NodeJSHostingView, LoginView, SignupView, SignupValidateView, SignupValidatedView, IndexView, \
OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView,\
VirtualMachineView, OrdersHostingDeleteView, NotificationsView, \
MarkAsReadNotificationView, PasswordResetView, PasswordResetConfirmView, HostingPricingView,\
@ -35,9 +35,11 @@ urlpatterns = [
name='read_notification'),
url(r'login/?$', LoginView.as_view(), name='login'),
url(r'signup/?$', SignupView.as_view(), name='signup'),
url(r'signup-validate/?$', SignupValidateView.as_view(), name='signup-validate'),
url(r'reset-password/?$', PasswordResetView.as_view(), name='reset_password'),
url(r'reset-password-confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
PasswordResetConfirmView.as_view(), name='reset_password_confirm'),
url(r'^logout/?$', 'django.contrib.auth.views.logout',
{'next_page': '/hosting/login?logged_out=true'}, name='logout')
{'next_page': '/hosting/login?logged_out=true'}, name='logout'),
url(r'^validate/(?P<validate_slug>.*)/$', SignupValidatedView.as_view(), name='validate')
]

View file

@ -18,7 +18,7 @@ from guardian.mixins import PermissionRequiredMixin
from stored_messages.settings import stored_messages_settings
from stored_messages.models import Message
from stored_messages.api import mark_read
from django.utils.safestring import mark_safe
from membership.models import CustomUser, StripeCustomer
from utils.stripe_utils import StripeUtils
@ -32,6 +32,7 @@ from .mixins import ProcessVMSelectionMixin
from opennebula_api.models import OpenNebulaManager
from opennebula_api.serializers import VirtualMachineSerializer,\
VirtualMachineTemplateSerializer
from django.utils.translation import ugettext_lazy as _
from oca.exceptions import OpenNebulaException
@ -199,12 +200,39 @@ class SignupView(CreateView):
name = form.cleaned_data.get('name')
email = form.cleaned_data.get('email')
password = form.cleaned_data.get('password')
this_base_url = "{0}://{1}".format(self.request.scheme, self.request.get_host())
CustomUser.register(name, password, email, app='dcl', base_url=this_base_url)
CustomUser.register(name, password, email)
auth_user = authenticate(email=email, password=password)
login(self.request, auth_user)
return HttpResponseRedirect(reverse_lazy('hosting:signup-validate'))
return HttpResponseRedirect(self.get_success_url())
class SignupValidateView(TemplateView):
template_name = "hosting/signup_validate.html"
def get_context_data(self, **kwargs):
context = super(SignupValidateView, self).get_context_data(**kwargs)
login_url = reverse('hosting:login')
message= _("Thank you for signing up. We have sent an email to you. Please follow the instructions in it to activate your account. Once activated, you can login using ") + '<a href="' + login_url +'">login</a>'
section_title='Sign up'
context['message'] = mark_safe(message)
context['section_title'] = section_title
return context
class SignupValidatedView(SignupValidateView):
template_name = "hosting/signup_validate.html"
def get_context_data(self, **kwargs):
context = super(SignupValidateView, self).get_context_data(**kwargs)
validated = CustomUser.validate_url(self.kwargs['validate_slug'])
login_url = reverse('hosting:login')
if validated:
message= _("Your account has been activated. You can now ") + '<a href="' + login_url +'">login</a>'
section_title=_('Account activation')
else:
message= _("Sorry. Your request is invalid.") + '<a href="' + login_url +'">login</a>'
section_title=_('Account activation')
context['message'] = mark_safe(message)
context['section_title'] = section_title
return context
class PasswordResetView(PasswordResetViewMixin):