-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
login works need to continue work on registration
- Loading branch information
Showing
12 changed files
with
130 additions
and
59 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,28 +22,70 @@ def index(request): | |
|
||
# sign up page | ||
def signUp(request): | ||
if request.method == "POST": | ||
name = request.post['name'] | ||
email = request.post['email'] | ||
phoneNum = request.post['phoneNum'] | ||
|
||
form = UserForm(data = request.POST) | ||
|
||
if form.is_valid(): | ||
user = form.save() | ||
|
||
user.is_active = False | ||
user.save() | ||
|
||
uniqueURL = URLCalendar(calendar=urlGenerator.createURL()) | ||
newStudent = Student(name=name, email=email, phone_num=phoneNum, status=False, calendar_link=uniqueURL) | ||
newStudent.save() | ||
|
||
html_msg = f"<p><a href='{request.build_absolute_uri('/register/confirm/')}{user.id}'>Click here to activate your account!</a></p>" | ||
mail.send_mail("Account Confirmation", "Please confirm your account registration.", settings.EMAIL_HOST_USER, [user.email], html_message=html_msg) | ||
else: | ||
pass | ||
else: | ||
form = UserCreationForm() | ||
return render(request, 'sign-up.html', {}) | ||
|
||
# sign up page | ||
def userLogin(request): | ||
if request.method == "POST": | ||
username = request.POST['username'] | ||
password = request.POST['password'] | ||
|
||
user = authenticate(username=username, password=password) | ||
|
||
# valid user | ||
if user: | ||
# user is valid, active, and authenticated | ||
if user.is_active: | ||
login(request, user) | ||
request.session['is_login'] = True | ||
request.session['user_name'] = username | ||
# user_id = User.objects.filter(username = username).values('id').first() | ||
# request.session['user_id'] = user_id['id'] | ||
return render(request, 'dashboard.html', {'error': 'Success and account is activated'}) | ||
|
||
# user is valid, but not active | ||
else: | ||
return render(request, 'login.html', {'error': 'Success, but account is deactivated'}) | ||
|
||
# user doesn't exist | ||
else: | ||
return render(request, 'login.html', {'error': 'Invalid login credentials'}) | ||
|
||
return render(request, 'login.html', {}) | ||
|
||
def save_university(request): | ||
if request.method == "POST": | ||
newUni = University(name="Rensselaer Polytechnic Institute", domain="rpi.edu", registeredStudents=0) | ||
newUni.save() | ||
else: | ||
pass | ||
|
||
def save_student(request): | ||
if request.method == "POST": | ||
uniqueURL = URLCalendar(calendar=urlGenerator.createURL()) | ||
newStud = Student(name="Nishant Srivastava", email="[email protected]", phone_num=5186182796, calendar_link=uniqueURL) | ||
newStud.save() | ||
else: | ||
pass | ||
|
||
def register(request): | ||
pass | ||
|
||
def login(request): | ||
pass | ||
|
||
def otp(): | ||
pass |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,27 +4,37 @@ | |
<!-- put main code here --> | ||
{% block content %} | ||
|
||
<div class="card"> | ||
<div class="card-content"> | ||
<p class="title"> | ||
“There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors.” | ||
</p> | ||
<p class="subtitle"> | ||
Jeff Atwood | ||
</p> | ||
<center> | ||
<div class="field" style="width:50%;"> | ||
<label class="label">Name</label> | ||
<div class="control"> | ||
<input class="input" type="text" placeholder="John Doe"> | ||
</div> | ||
<br> | ||
<label class="label">Email</label> | ||
<div class="control"> | ||
<input class="input" type="email" placeholder="[email protected]"> | ||
</div> | ||
<br> | ||
<label class="label">Password</label> | ||
<div class="control"> | ||
<input class="input" type="password" placeholder="*********"> | ||
</div> | ||
<br> | ||
<label class="label">Retype Password</label> | ||
<div class="control"> | ||
<input class="input" type="password" placeholder="*********"> | ||
</div> | ||
<br> | ||
<label class="label">Phone Number</label> | ||
<div class="control"> | ||
<input class="input" type="number" placeholder="123-456-7890"> | ||
</div> | ||
<br> | ||
<div class="control"> | ||
<button id="signUpButton" class="button is-danger">Sign Up</button> | ||
</div> | ||
</div> | ||
<footer class="card-footer"> | ||
<p class="card-footer-item"> | ||
<span> | ||
View on <a href="https://twitter.com/codinghorror/status/506010907021828096">Twitter</a> | ||
</span> | ||
</p> | ||
<p class="card-footer-item"> | ||
<span> | ||
Share on <a href="#">Facebook</a> | ||
</span> | ||
</p> | ||
</footer> | ||
</div> | ||
</center> | ||
|
||
{% endblock %} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,16 @@ | |
|
||
USE_TZ = True | ||
|
||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||
EMAIL_USE_TLS = True | ||
EMAIL_HOST = 'smtp.gmail.com' | ||
# Host email ([email protected]) | ||
EMAIL_HOST_USER = '[email protected]' | ||
# Host email password | ||
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_PASSWORD") | ||
EMAIL_PORT = 587 | ||
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/2.2/howto/static-files/ | ||
|
@@ -126,4 +136,4 @@ | |
|
||
STATICFILES_DIRS = ( | ||
os.path.join(BASE_DIR, 'static/'), | ||
) | ||
) |