Browse Source

when registering a player, validate the input name against the server's configured player name regex. fixes #44

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
07b132a378
  1. 7
      pyweb/mumble/forms.py
  2. 1
      pyweb/mumble/views.py

7
pyweb/mumble/forms.py

@ -14,6 +14,8 @@
* GNU General Public License for more details.
"""
import re
from django import forms
from django.forms import Form, ModelForm
from django.utils.translation import ugettext_lazy as _
@ -46,8 +48,13 @@ class MumbleUserForm( ModelForm ):
def clean_name( self ):
name = self.cleaned_data['name'];
if self.server.player and re.compile( self.server.player ).match( name ) is None:
raise forms.ValidationError( _( "That name is forbidden by the server." ) );
if not self.instance.id and len( self.server.ctl.getRegisteredPlayers( self.server.srvid, name ) ) > 0:
raise forms.ValidationError( _( "Another player already registered that name." ) );
return name;
def clean_password( self ):

1
pyweb/mumble/views.py

@ -108,6 +108,7 @@ def show( request, server ):
displayTab = 1;
else:
regform = MumbleUserForm( request.POST, instance=user );
regform.server = srv;
if regform.is_valid():
regform.save();
return HttpResponseRedirect( reverse( show, kwargs={ 'server': int(server), } ) );

Loading…
Cancel
Save