File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
from django import forms
2
- from django .contrib .auth .forms import AuthenticationForm
2
+ from django .contrib .admin .forms import AdminAuthenticationForm
3
3
4
4
5
- class CMSToolbarLoginForm (AuthenticationForm ):
5
+ class CMSToolbarLoginForm (AdminAuthenticationForm ):
6
6
7
7
def __init__ (self , * args , ** kwargs ):
8
8
super (CMSToolbarLoginForm , self ).__init__ (* args , ** kwargs )
Original file line number Diff line number Diff line change @@ -187,6 +187,15 @@ def test_toolbar_login(self):
187
187
self .assertRedirects (response , '/en/admin/' )
188
188
self .assertTrue (settings .SESSION_COOKIE_NAME in response .cookies )
189
189
190
+ def test_toolbar_login_non_staff (self ):
191
+ admin = self .get_nonstaff ()
192
+ endpoint = reverse ('cms_login' ) + '?next=/en/admin/'
193
+ username = getattr (admin , get_user_model ().USERNAME_FIELD )
194
+ password = getattr (admin , get_user_model ().USERNAME_FIELD )
195
+ response = self .client .post (endpoint , data = {'username' : username , 'password' : password })
196
+ self .assertRedirects (response , '/en/admin/?cms_toolbar_login_error=1' , target_status_code = 302 )
197
+ self .assertFalse (settings .SESSION_COOKIE_NAME in response .cookies )
198
+
190
199
def test_toolbar_login_error (self ):
191
200
admin = self .get_superuser ()
192
201
endpoint = reverse ('cms_login' ) + '?next=/en/admin/'
You can’t perform that action at this time.
0 commit comments