diff --git a/templates/include/messages.html b/templates/include/messages.html new file mode 100644 index 0000000..194e3b5 --- /dev/null +++ b/templates/include/messages.html @@ -0,0 +1,9 @@ +{% if messages %} + {% for message in messages %} +{# #} + + {% endfor %} +{% endif %} diff --git a/templates/registration/login.html b/templates/registration/login.html old mode 100644 new mode 100755 index d7b988b..5fcf18b --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -1,53 +1,134 @@ -{% extends "base_generic.html" %} +{% load static %} -{% block content %} + + + + Login + + + + + + + + + + + + + +
+
+
+{#
#} +{# #} +{#
#} +
+
+
+ {% csrf_token %} - {% if form.errors %} -

Your phone number and otp didn't match. Please try again.

- {% endif %} - {% if next %} - {% if user.is_authenticated %} -

Your account doesn't have access to this page. To proceed, - please login with an account that has access.

- {% else %} -

Please login to see this page.

- {% endif %} - {% endif %} +
+ + + +
+
+
+
+
+
+
- - {% csrf_token %} - +
+ + +
- - - - - - +
+ +
+ +
+ {% include "include/messages.html" %} +
+
+ + - - - - -
{{ form.phone_number.label_tag }}{{ form.phone_number }}requet otp
{{ form.otp.label_tag }}{{ form.otp }}
- - - +
+
+
+ + //if (phoneNumberRegex.test(phoneNumber)) { + var data = {'phone_number': phoneNumber} + //} else { + // var data = {'username': mobileNumberOrUsername} + //} -{% endblock %} \ No newline at end of file + $.post("/request_otp/", data).done( + function (result) { + console.log(result); + if (result.hasOwnProperty('ttl')) { + + bootstrap_alert.info('رمز یکبار مصرف ارسال شد'); + $("#request-otp").prop('disabled', true) + + + var i = result['ttl']; + var counterBack = setInterval(function () { + i--; + if (i >= 0) { + document.getElementById("ttl").style.width = (i + 1) / 3 + "%"; + } else { + $("#request-otp").prop('disabled', false) + document.getElementById("ttl").style.width = "0%"; + clearTimeout(counterBack); + } + + }, 1000); + } else { + console.log(result) + } + + } + ).fail(function (result) { + bootstrap_alert.warning(result.responseJSON[Object.keys(result.responseJSON)[0]]); + console.log(result.responseJSON) + }); + } + ); + + + +