Commit d4196f2efdc73cd46f4430144fdb4c5a9cc1c459
1 parent
c3996a51
Exists in
master
and in
3 other branches
Applying deny register config
Showing
2 changed files
with
16 additions
and
4 deletions
Show diff stats
users/templates/users/login.html
... | ... | @@ -59,9 +59,11 @@ |
59 | 59 | <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 text-center"> |
60 | 60 | <button type="submite" class="btn btn-success btn-raised btn-block" form="form-login" style="position: initial;"> {% trans 'Log in' %} </button> |
61 | 61 | </div> |
62 | - <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 text-center"> | |
63 | - <a class="btn btn-default btn-raised btn-block" href="{% url 'users:signup' %}" formaction="#" style="position: initial;">{% trans 'Sign Up' %}</a> | |
64 | - </div> | |
62 | + {% if not deny_register %} | |
63 | + <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 text-center"> | |
64 | + <a class="btn btn-default btn-raised btn-block" href="{% url 'users:signup' %}" formaction="#" style="position: initial;">{% trans 'Sign Up' %}</a> | |
65 | + </div> | |
66 | + {% endif %} | |
65 | 67 | </div> |
66 | 68 | </div> |
67 | 69 | <div class="row"> | ... | ... |
users/views.py
... | ... | @@ -304,6 +304,14 @@ class RegisterUser(generic.edit.CreateView): |
304 | 304 | |
305 | 305 | return super(RegisterUser, self).form_valid(form) |
306 | 306 | |
307 | + def dispatch(self, request, *args, **kwargs): | |
308 | + security = Security.objects.get(id = 1) | |
309 | + | |
310 | + if security.allow_register: | |
311 | + return redirect(reverse_lazy('users:login')) | |
312 | + | |
313 | + return super(RegisterUser, self).dispatch(request, *args, **kwargs) | |
314 | + | |
307 | 315 | class ForgotPassword(generic.FormView): |
308 | 316 | template_name = "users/forgot_password.html" |
309 | 317 | success_url = reverse_lazy('users:login') |
... | ... | @@ -401,12 +409,14 @@ class PasswordResetConfirmView(generic.FormView): |
401 | 409 | def login(request): |
402 | 410 | context = {} |
403 | 411 | context['title'] = _('Log In') |
412 | + security = Security.objects.get(id = 1) | |
413 | + | |
414 | + context['deny_register'] = security.allow_register | |
404 | 415 | |
405 | 416 | if request.POST: |
406 | 417 | username = request.POST['email'] |
407 | 418 | password = request.POST['password'] |
408 | 419 | user = authenticate(username=username, password=password) |
409 | - security = Security.objects.get(id = 1) | |
410 | 420 | |
411 | 421 | if user is not None: |
412 | 422 | if not security.maintence or user.is_staff: | ... | ... |