Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mysite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.sqlite3
2 changes: 2 additions & 0 deletions mysite/account/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
credentials.py
__pycache__
3 changes: 2 additions & 1 deletion mysite/account/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#password: adminpassword

from django.contrib import admin
from .models import Case, Profile, Passwords
from .models import Case, Profile, Passwords, Otp_database

# Register your models here.
admin.site.register(Case)
admin.site.register(Passwords)
admin.site.register(Profile)
admin.site.register(Otp_database)
22 changes: 22 additions & 0 deletions mysite/account/migrations/0002_otp_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.0.9 on 2019-03-17 17:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('account', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Otp_database',
fields=[
('username', models.CharField(max_length=20, primary_key=True, serialize=False)),
('otp_id', models.CharField(max_length=10)),
('otp_text', models.CharField(max_length=10)),
('timestamp', models.DateTimeField()),
],
),
]
Binary file not shown.
Binary file modified mysite/account/migrations/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions mysite/account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ class Passwords(models.Model):
email = models.CharField(max_length=100)
encrypted_password = models.CharField(max_length=100)
belongs_to = models.ForeignKey(Profile, on_delete=models.CASCADE)

class Otp_database(models.Model):
username = models.CharField(max_length=20, primary_key=True)
otp_id = models.CharField(max_length=10)
otp_text = models.CharField(max_length=10)
timestamp = models.DateTimeField()
26 changes: 26 additions & 0 deletions mysite/account/sendOTP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from twilio.rest import Client
from .credentials import account_sid, auth_token, my_cell, my_twilio

# Find these values at https://twilio.com/user/account


my_msg = ''.join(['Hi Mayur!!\n' for i in range(100)])
my_msg+="-from MATHUR ;) "


mayur_cell="+917678599539"
def send_otp(reg_number,num):
client = Client(account_sid, auth_token)
reg_number=my_twilio
otp= "Your One Time Password is: "
print(otp+num)
message = client.messages \
.create(
body=otp+num,
from_=reg_number,
status_callback='http://postb.in/1234abcd',
to=my_cell
)
return message.sid

#print(message)
51 changes: 51 additions & 0 deletions mysite/account/static/account/otp_css.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.new-login-area{
padding:24px;
}
h3 {
font-size: 36px;
line-height: 30px;
}
label {
font-size: 24px;
}
.request-otp-header {
margin: 40px 0px;
font-weight: 900;

}
.login-label label {
color: #c74032;
font-weight: 600;
}
.input-edit {
border: none !important;
border-bottom: 5px solid #ccc !important;
padding: 6px 0px;
opacity: 0.8;
}
.input-edit:focus {
border-bottom-color: #c74032 !important;
box-shadow: none;
outline: 0;
}

.request-otp {
margin-top: 40px;
background: linear-gradient(#c74032, #91041b);
font-size: 14px;
color: #fff;
}
.request-otp:focus {
box-shadow: none;
}
.fa-chevron-left {
cursor: pointer;
}
.resend-otp{
margin-top:6px;
cursor:pointer;
}
.btn-default{
color: #fff;
background-color: #c74032;
}
20 changes: 20 additions & 0 deletions mysite/account/static/account/otp_js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//$('#verify-otp').hide();
//$('#request-otp').on('click',function(){
//// $.ajax({
//// type: "GET",
//// url: '\one_time_password_request',
//// success: function(data){
//// alert(data);
//// }
//// });
//// $.get('/one_time_password_request', function (data) {
//// //console.log(data);
//// alert(data);
//// });
// $('#sign-in').hide();
// $('#verify-otp').show();
//});
//$('.fa-chevron-left').on('click',function(){
// $('#sign-in').show();
// $('#verify-otp').hide();
//});
2 changes: 1 addition & 1 deletion mysite/account/templates/account/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ <h5 style="color: Yellow; margin-left: 40px; margin-top: 0px; margin">Your suitc
{% block body %}
{% endblock %}
</body>
</html>
</html>
20 changes: 20 additions & 0 deletions mysite/account/templates/account/change_password.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'account/base.html' %}
{% block body %}
<body>
<form method="POST">
{% csrf_token %}
<fieldset style="margin-left: 20px; margin-right: 20px;">
<legend style="font-family: 'Oswald', sans-serif;">Change your Password.</legend>
<div class="form-group">
<label class="col-form-label" for="inputDefault">Enter Password</label>
<input type="password" class="form-control" name="password1" id="inputDefault" placeholder="Enter Password">
</div>
<div class="form-group">
<label class="col-form-label" for="exampleInputPassword1">Enter Password Again</label>
<input type="password" class="form-control" id="exampleInputPassword1" name="password2" placeholder="Enter Password Again">
</div>
<input type="submit" class="btn btn-primary" value="Submit">
</fieldset>
</form>
</body>
{% endblock %}
1 change: 1 addition & 0 deletions mysite/account/templates/account/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ <h5 id="alert" style="margin-left: 20px; margin-right: 20px; color: red;"></h5>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
<button type="submit" class="btn btn-primary forgot-password" onClick="location.href='{% url 'otp_request_page' %}'" style="margin-top: 5px; margin-left: 20px;">Forgot Password</button>
<button type="submit" class="btn btn-primary" onClick="location.href='{% url 'register' %}'" style="float: right; margin-right: 20px;">REGISTER</button>
<label class="col-form-label" for="inputDefault" style="float: right; margin-right: 20px;">Don't have an account?</label>
</body>
Expand Down
62 changes: 62 additions & 0 deletions mysite/account/templates/account/otp_input_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{% extends 'account/base.html' %}
{% block body %}
<html>
<head>
<title>
OTP Request
</title>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../../static/account/otp_css.css">
<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>-->

</head>
<body>
<script>
var error = {{error}}
console.log(error);
if(error == 0){
alert("OTP EXPIRED!");
window.location.href = "/otp_request_page";
}
else if(error == 1){
alert("OTP NOT MATCHED!");
window.location.href = "/otp_request_page";
}
</script>
<div class="container new-login-area">
<!--
<form action="/one_time_password_request">
<div id='sign-in' class='login-setup-section'>
<h3 class="request-otp-header">Please verify your Username</h3>
<div class="form-group login-label">
<label for="inputusername">Enter Username</label>
<input type="text" class="form-control input-edit" placeholder='Enter Username' name="input_username">
</div>
<input type="submit" class="btn btn-default btn-lg btn-block request-otp" id='request-otp' value="Get OTP">
<input type="submit" value="Submit" />
</div>
</form>
-->
<form action="one_time_password_input" method="post">
{% csrf_token %}
<div id='verify-otp' class="login-setup-section">
<h3 class="request-otp-header">Verify OTP</h3>
<div class="form-group login-label">
<label for="inputnumber">One Time Password</label>
<input type="password" class="form-control input-edit" placeholder='Enter OTP' name="otp_number">
<label class="pull-right resend-otp">Resend OTP</label>
</div>
<input type="submit" class="btn btn-default btn-lg btn-block request-otp " value="Verify">
</div>
</form>
</div>

<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>-->
<!--<script src="../../static/account/otp_js.js"></script>-->

</body>
</html>
{% endblock %}
60 changes: 60 additions & 0 deletions mysite/account/templates/account/otp_request_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{% extends 'account/base.html' %}
{% block body %}
<html>
<head>
<title>
OTP Request
</title>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../../static/account/otp_css.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

</head>
<body>

<script>

error = {{error}};
if(error){
alert("INVALID USERNAME");
}

</script>

<div class="container new-login-area">
<form action="/one_time_password_request">
<div id='sign-in' class='login-setup-section'>
<h3 class="request-otp-header">Please verify your Username</h3>
<div class="form-group login-label">
<label for="inputusername">Enter Username</label>
<input type="text" class="form-control input-edit" placeholder='Enter Username' name="input_username">
</div>
<input type="submit" class="btn btn-default btn-lg btn-block request-otp" id='request-otp' value="Get OTP">
<!-- <input type="submit" value="Submit" />-->
</div>
</form>
<!--
<form action="/one_time_password_request">
<div id='verify-otp' class="login-setup-section">
<i class="fa fa-chevron-left" aria-hidden="false"></i>
<h3 class="request-otp-header">Verify OTP</h3>
<div class="form-group login-label">
<label for="inputnumber">One Time Password</label>
<input type="password" class="form-control input-edit" placeholder='Enter OTP' id="number">
<label class="pull-right resend-otp">Resend OTP</label>
</div>
<button type="button" class="btn btn-default btn-lg btn-block request-otp ">Verify</button>
</div>
</form>
-->
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="../../static/account/otp_js.js"></script>

</body>
</html>
{% endblock %}
10 changes: 10 additions & 0 deletions mysite/account/templates/account/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>This is your profile.</h1>
</body>
</html>
4 changes: 4 additions & 0 deletions mysite/account/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
url(r'login/', views.login, name='login'),
url(r'profile/(?P<id>[0-9]+)/', views.profile, name='profile'),
url(r'addPassword/(?P<id>[0-9]+)/', views.addPassword, name='addPassword'),
url(r'otp_request_page/', views.render_otp_request_page, name='otp_request_page'),
url(r'one_time_password_request/',views.sendOTP,name="one_time_password_request"),
url(r'one_time_password_enter/(?P<username>[A-Za-z0-9_-]{3,20})/',views.render_otp_input_page,name="one_time_password_enter"),
url(r'change_password/(?P<username>[A-Za-z0-9_-]{3,20})/', views.change_password_view, name='change_password'),
]
Loading