From f1df5335758abc1b815002b3ff415f349761256d Mon Sep 17 00:00:00 2001
From: Marius Gavrilescu <marius@ieval.ro>
Date: Sat, 25 Jan 2014 22:22:25 +0200
Subject: [PATCH] Update fields and enforce limits

---
 lib/Gruntmaster/Handlers.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/Gruntmaster/Handlers.pm b/lib/Gruntmaster/Handlers.pm
index c9a6c70..dec98dc 100644
--- a/lib/Gruntmaster/Handlers.pm
+++ b/lib/Gruntmaster/Handlers.pm
@@ -67,15 +67,16 @@ sub submit{
 sub register{
 	my $r = shift;
 	my $req = Apache2::Request->new($r);
-	my ($username, $password, $confirm_password, $name, $email, $town, $university) = map {scalar $req->param($_)} 'username', 'password', 'confirm_password', 'name', 'email', 'town', 'university';
+	my ($username, $password, $confirm_password, $name, $email, $phone, $town, $university, $level) = map { die if length > 200; $_ } map {scalar $req->param($_)} qw/username password confirm_password name email phone town university level/;
 
 	local $Apache2::Authen::Passphrase::rootdir = $r->dir_config('AuthenPassphraseRootdir');
 	return aputs $r, 'Bad username. Allowed characters are letters, digits and underscores, and the username must be between 2 and 20 characters long.' unless $username =~ USER_REGEX;
 	return aputs $r, 'Username already in use' if -e "$Apache2::Authen::Passphrase::rootdir/$username.yml";
 	return aputs $r, 'The two passwords do not match' unless $password eq $confirm_password;
+	return aputs $r, 'All fields are required' if grep { !length } $username, $password, $confirm_password, $name, $email, $phone, $town, $university, $level;
 	pwset $username, $password;
 
-	insert_user $username, name => $name, email => $email, town => $town, university => $university;
+	insert_user $username, name => $name, email => $email, phone => $phone, town => $town, university => $university, level => $level;
 
 	aputs $r, 'Registered successfully';
 }
-- 
2.39.5