Prevent rogue registrations from crashing db

This commit is contained in:
Stephan
2016-12-07 17:02:14 +01:00
parent 1e5a959f25
commit 78c327e3f3
@@ -60,6 +60,28 @@ namespace OurUmbraco.Our.Controllers
return Redirect("/");
}
// these values are enforced in MemberDto which is internal ;-(
// we should really have ways to query for Core meta-data!
const int maxEmailLength = 900; // 1000*.9 for safety
const int maxLoginNameLength = 900; // 1000*.9 for safety
const int maxPasswordLength = 900; // 1000*.9 for safety
const int maxPropertyLength = 900; // keep it safe too
if (model.Email.Length > maxEmailLength
|| model.Name.Length > maxLoginNameLength
|| model.Password.Length > maxPasswordLength
|| model.Location.Length > maxPropertyLength
|| model.Longitude.Length > maxPropertyLength
|| model.Latitude.Length > maxPropertyLength
|| model.Company.Length > maxPropertyLength
|| model.TwitterAlias.Length > maxPropertyLength
)
{
// has to be a rogue registration
// go away!
return Redirect("/");
}
var member = memberService.CreateMember(model.Email, model.Email, model.Name, "member");
member.SetValue("location", model.Location);
member.SetValue("longitude", model.Longitude);