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
FROM python:3.10.12-slim-buster as python-base | |
# python | |
ENV PYTHONUNBUFFERED=1 \ | |
# prevents python creating .pyc files | |
PYTHONDONTWRITEBYTECODE=1 \ | |
# poetry | |
# make poetry install to this location | |
POETRY_HOME="/opt/poetry" \ | |
# make poetry create the virtual environment in the project's root |
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
import { createBrowserRouter } from 'react-router-dom' | |
import { Login } from '../authentication/Login/Login' | |
const ROUTES = [ | |
{ | |
path: '/login', | |
element: <Login />, | |
}, | |
] |
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
import { useNavigate } from 'react-router-dom' | |
import { API } from '../../api' | |
export const Login = () => { | |
const navigate = useNavigate() | |
const onSubmit = (e) => { | |
e.preventDefault() | |
const formData = new FormData(e.target) |
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
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm | |
from django.utils.translation import ugettext_lazy as _ | |
from django import forms | |
from .models import User, MoodleDetails | |
class RegisterForm(UserCreationForm): | |
email = forms.EmailField(widget=forms.TextInput(attrs={'class': "user-input","placeholder":"Email address","type":"email"})) | |
username = forms.CharField(widget=forms.TextInput(attrs={'class': "user-input","placeholder":"Username"})) | |
password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput(attrs={"class":"pass-input", "placeholder":"Password"})) |
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
class SigninView(views.LoginView): | |
""" | |
Sign in view template | |
""" | |
template_name = "registration/login.html" | |
authentication_form = SignInForm | |
def register(request): | |
""" |
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
class User(AbstractUser): | |
username = models.CharField(max_length=20, unique=False) | |
email = models.EmailField(_('email address'), unique=True) | |
USERNAME_FIELD = 'email' | |
REQUIRED_FIELDS = ["username"] | |
objects = CustomUserManager() | |
def __str__(self): |
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
from django.contrib.auth.base_user import BaseUserManager | |
from django.utils.translation import ugettext_lazy as _ | |
class CustomUserManager(BaseUserManager): | |
""" | |
Custom user model manager where email is the unique identifiers | |
for authentication instead of usernames. | |
""" | |
def create_user(self, email, username, password, **extra_fields): |