Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.contrib.auth.forms import AuthenticationForm
- from django import forms
- from django.contrib.auth import authenticate
- #from django.contrib.auth.models import User
- class LoginAuth(AuthenticationForm):
- username = forms.CharField(max_length=30, label='Username',
- widget=forms.TextInput(attrs={
- 'id': 'username', 'name': 'username'
- }))
- password = forms.CharField(max_length=30, label='Password',
- widget=forms.PasswordInput(attrs={
- 'id': 'password', 'name': 'password'
- }))
- def login_auth(self):
- user = authenticate(username = self.username, password = self.password)
- if user is not None:
- if user.is_active and user.is_staff is True:
- return 'admin'
- elif user.is_active and user.is_staff is False:
- return 'ordinary'
- else:
- return 'deny'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement