mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-28 15:59:55 -04:00
Laying down foundation for login and account creation
This commit is contained in:
parent
b8c033b71f
commit
06908a3e60
|
@ -14,7 +14,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div class="d-flex align-items-center justify-content-center" style="height: 100vh">
|
||||
<a href="https://ion.tjhsst.edu/oauth/authorize/?response_type=code&client_id=QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F&scope=read&state=bVchSMe63qFXMYxOYthCfuqEr9FAdI" title="Ion" class="border border-dark p-3 btn btn-lg mx-auto" style="box-shadow: 5px 10px;">
|
||||
<a href="https://ion.tjhsst.edu/oauth/authorize/?response_type=code&client_id=QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F&scope=read&state=5EVwgQRAWaQngvshhCbYiTwC9Rpi7N" title="Ion" class="border border-dark p-3 btn btn-lg mx-auto" style="box-shadow: 5px 10px;">
|
||||
<img src="https://ion.tjhsst.edu/static/img/favicon.png">
|
||||
Sign in with Ion
|
||||
</a>
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
from socket import *
|
||||
from selenium import webdriver
|
||||
import http.server
|
||||
import socketserver
|
||||
import threading
|
||||
from http.server import HTTPServer
|
||||
|
||||
class HTTPServer(BaseHTTPServer.HTTPServer):
|
||||
|
||||
def create_server():
|
||||
port = 8000
|
||||
handler = http.server.SimpleHTTPRequestHandler
|
||||
httpd = socketserver.TCPServer(("", port), handler)
|
||||
print("serving at port:" + str(port))
|
||||
httpd.serve_forever()
|
||||
_continue = True
|
||||
|
||||
def serve_until_shutdown(self):
|
||||
while self._continue:
|
||||
self.handle_request()
|
||||
|
||||
threading.Thread(target=create_server).start()
|
||||
def shutdown(self):
|
||||
self._continue = False
|
||||
# We fire a last request at the server in order to take it out of the
|
||||
# while loop in `self.serve_until_shutdown`.
|
||||
try:
|
||||
urllib2.urlopen(
|
||||
'http://%s:%s/' % (self.server_name, self.server_port))
|
||||
except urllib2.URLError:
|
||||
# If the server is already shut down, we receive a socket error,
|
||||
# which we ignore.
|
||||
pass
|
||||
self.server_close()
|
||||
|
||||
print("Server has started. Continuing..")
|
||||
|
||||
browser = webdriver.Chrome()
|
||||
browser.get("http://localhost:8000")
|
||||
|
||||
assert "<title>" in browser.page_source
|
||||
|
|
|
@ -20,11 +20,12 @@ scope = ["read"]
|
|||
|
||||
def main():
|
||||
print("")
|
||||
print(" SSSSS CCCCC HH HH OOOOO OOOOO LL OOOOO SSSSS ")
|
||||
print("SS CC C HH HH OO OO OO OO LL OO OO SS ")
|
||||
print(" SSSSS CC HHHHHHH OO OO OO OO LL OO OO SSSSS ")
|
||||
print(" SS CC C HH HH OO OO OO OO LL OO OO SS")
|
||||
print(" SSSSS CCCCC HH HH OOOO0 OOOO0 LLLLLLL OOOO0 SSSSS ")
|
||||
print("░██████╗██╗░░██╗░█████╗░░█████╗░██╗░░░░░ ░█████╗░░██████╗")
|
||||
print("██╔════╝██║░██╔╝██╔══██╗██╔══██╗██║░░░░░ ██╔══██╗██╔════╝")
|
||||
print("╚█████╗░█████═╝░██║░░██║██║░░██║██║░░░░░ ██║░░██║╚█████╗░")
|
||||
print("░╚═══██╗██╔═██╗░██║░░██║██║░░██║██║░░░░░ ██║░░██║░╚═══██╗")
|
||||
print("██████╔╝██║░╚██╗╚█████╔╝╚█████╔╝███████╗ ╚█████╔╝██████╔╝")
|
||||
print("╚═════╝░╚═╝░░╚═╝░╚════╝░░╚════╝░╚══════╝ ░╚════╝░╚═════╝░")
|
||||
print("")
|
||||
|
||||
if not os.path.exists(".profile"):
|
||||
|
@ -53,15 +54,14 @@ def authenticate():
|
|||
template.close()
|
||||
index.close()
|
||||
|
||||
# server = Thread(target=create_server)
|
||||
# server.daemon = True
|
||||
# server.start()
|
||||
server = Thread(target=create_server)
|
||||
server.daemon = True
|
||||
server.start()
|
||||
|
||||
browser = webdriver.Chrome()
|
||||
browser.get("localhost:8000/")
|
||||
|
||||
while "http://localhost:8000/?code" not in browser.current_url:
|
||||
http.server.
|
||||
time.sleep(0.25)
|
||||
|
||||
url = browser.current_url
|
||||
|
@ -89,11 +89,12 @@ def authenticate():
|
|||
first_name = profile['first_name']
|
||||
last_name = profile['last_name']
|
||||
|
||||
os.chdir("..")
|
||||
profileFile = open(".profile", "w")
|
||||
profileFile.write(profile)
|
||||
profileFile.write(profile.text())
|
||||
profileFile.close()
|
||||
|
||||
# server.stop
|
||||
# sys.exit
|
||||
|
||||
|
||||
def create_server():
|
||||
|
|
|
@ -5,7 +5,7 @@ import sys
|
|||
|
||||
|
||||
def main():
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolsite.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolos.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
ASGI config for skoolsite project.
|
||||
ASGI config for skoolos project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
|
@ -11,6 +11,6 @@ import os
|
|||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolsite.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolos.settings')
|
||||
|
||||
application = get_asgi_application()
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Django settings for skoolsite project.
|
||||
Django settings for skoolos project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 3.0.7.
|
||||
|
||||
|
@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
|
|||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'users.apps.UsersConfig',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
|
@ -39,6 +40,8 @@ INSTALLED_APPS = [
|
|||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
'api',
|
||||
'crispy_forms',
|
||||
|
||||
|
||||
]
|
||||
|
||||
|
@ -60,7 +63,7 @@ MIDDLEWARE = [
|
|||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'skoolsite.urls'
|
||||
ROOT_URLCONF = 'skoolos.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
|
@ -78,7 +81,7 @@ TEMPLATES = [
|
|||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'skoolsite.wsgi.application'
|
||||
WSGI_APPLICATION = 'skoolos.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
|
@ -129,3 +132,7 @@ USE_TZ = True
|
|||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
||||
|
||||
LOGIN_REDIRECT_URL = '/'
|
23
Website/skoolos/urls.py
Normal file
23
Website/skoolos/urls.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from django.urls import path
|
||||
from rest_framework import routers
|
||||
from api import views as api_views
|
||||
from django.contrib import admin
|
||||
from django.conf.urls import include
|
||||
from django.contrib.auth import views as auth_views
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'students', api_views.StudentViewSet)
|
||||
router.register(r'teachers', api_views.TeacherViewSet)
|
||||
router.register(r'assignments', api_views.AssignmentViewSet)
|
||||
router.register(r'classes', api_views.ClassesViewSet)
|
||||
router.register(r'files', api_views.DefFilesViewSet)
|
||||
|
||||
|
||||
# Wire up our API using automatic URL routing.
|
||||
# Additionally, we include login URLs for the browsable API.
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
path('api-auth/', include('rest_framework.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
path('login/', auth_views.LoginView.as_view(template_name="users/login.html"), name='login')
|
||||
]
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
WSGI config for skoolsite project.
|
||||
WSGI config for skoolos project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
|
@ -11,6 +11,6 @@ import os
|
|||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolsite.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolos.settings')
|
||||
|
||||
application = get_wsgi_application()
|
|
@ -1,22 +0,0 @@
|
|||
from django.urls import path
|
||||
from rest_framework import routers
|
||||
from api import views
|
||||
from django.contrib import admin
|
||||
from django.conf.urls import include
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'students', views.StudentViewSet)
|
||||
router.register(r'teachers', views.TeacherViewSet)
|
||||
router.register(r'assignments', views.AssignmentViewSet)
|
||||
router.register(r'classes', views.ClassesViewSet)
|
||||
router.register(r'files', views.DefFilesViewSet)
|
||||
|
||||
|
||||
# Wire up our API using automatic URL routing.
|
||||
# Additionally, we include login URLs for the browsable API.
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
path('api-auth/', include('rest_framework.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
|
||||
]
|
0
Website/users/__init__.py
Normal file
0
Website/users/__init__.py
Normal file
3
Website/users/admin.py
Normal file
3
Website/users/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
5
Website/users/apps.py
Normal file
5
Website/users/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class UsersConfig(AppConfig):
|
||||
name = 'users'
|
0
Website/users/migrations/__init__.py
Normal file
0
Website/users/migrations/__init__.py
Normal file
3
Website/users/models.py
Normal file
3
Website/users/models.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
104
Website/users/static/users/styles.css
Normal file
104
Website/users/static/users/styles.css
Normal file
|
@ -0,0 +1,104 @@
|
|||
@import url(https://fonts.googleapis.com/css?family=Roboto:300);
|
||||
|
||||
|
||||
|
||||
.login-page {
|
||||
width: 360px;
|
||||
padding: 8% 0 0;
|
||||
margin: auto;
|
||||
}
|
||||
.form {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
background: #FFFFFF;
|
||||
max-width: 360px;
|
||||
height; 100vh;
|
||||
margin: 0 auto 100px;
|
||||
padding: 45px;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
|
||||
}
|
||||
.form input {
|
||||
font-family: "Roboto", sans-serif;
|
||||
outline: 0;
|
||||
background: #f2f2f2;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
margin: 0 0 15px;
|
||||
padding: 15px;
|
||||
box-sizing: border-box;
|
||||
font-size: 14px;
|
||||
}
|
||||
.form button {
|
||||
font-family: "Roboto", sans-serif;
|
||||
text-transform: uppercase;
|
||||
outline: 0;
|
||||
background: #4CAF50;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
padding: 15px;
|
||||
color: #FFFFFF;
|
||||
font-size: 14px;
|
||||
-webkit-transition: all 0.3 ease;
|
||||
transition: all 0.3 ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
.form button:hover,.form button:active,.form button:focus {
|
||||
background: #43A047;
|
||||
}
|
||||
.form .message {
|
||||
margin: 15px 0 0;
|
||||
color: #b3b3b3;
|
||||
font-size: 12px;
|
||||
}
|
||||
.form .message a {
|
||||
color: #4CAF50;
|
||||
text-decoration: none;
|
||||
}
|
||||
.form .register-form {
|
||||
display: none;
|
||||
}
|
||||
.container {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
max-width: 300px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.container:before, .container:after {
|
||||
content: "";
|
||||
display: block;
|
||||
clear: both;
|
||||
}
|
||||
.container .info {
|
||||
margin: 50px auto;
|
||||
text-align: center;
|
||||
}
|
||||
.container .info h1 {
|
||||
margin: 0 0 15px;
|
||||
padding: 0;
|
||||
font-size: 36px;
|
||||
font-weight: 300;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
.container .info span {
|
||||
color: #4d4d4d;
|
||||
font-size: 12px;
|
||||
}
|
||||
.container .info span a {
|
||||
color: #000000;
|
||||
text-decoration: none;
|
||||
}
|
||||
.container .info span .fa {
|
||||
color: #EF3B3A;
|
||||
}
|
||||
body {
|
||||
background: #fff url("black_on_white.png") repeat;
|
||||
background-size: 512px;
|
||||
font-family: "Roboto", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.errorlist {
|
||||
|
||||
}
|
27
Website/users/templates/users/base.html
Normal file
27
Website/users/templates/users/base.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% load static %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'users/styles.css' %}">
|
||||
|
||||
<title>SkoolOS</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
a
|
||||
<!-- Bootstrap JS -->
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
16
Website/users/templates/users/login.html
Normal file
16
Website/users/templates/users/login.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
{% extends "users/base.html" %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block content %}
|
||||
<div class="login-page">
|
||||
<div class="form">
|
||||
<form class="login-form" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form | crispy }}
|
||||
<button type="submit">login</button>
|
||||
<p class="message">Not registered? <a href="#">Create an account with Ionreg</a></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
15
Website/users/templates/users/register.html
Normal file
15
Website/users/templates/users/register.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
{% extends "users/base.html" %}\
|
||||
|
||||
{% block content %}
|
||||
<div class="login-page">
|
||||
<div class="form">
|
||||
<form class="login-form" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form | crispy }}
|
||||
<button type="submit">login</button>
|
||||
<p class="message">Not registered? <a href="#">Create an account with Ionreg</a></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
3
Website/users/tests.py
Normal file
3
Website/users/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
Website/users/views.py
Normal file
3
Website/users/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
Loading…
Reference in New Issue
Block a user