update content and security fixes

This commit is contained in:
timurgordon 2022-10-26 10:29:29 +03:00
parent 4512701f59
commit 511f5073aa
4 changed files with 137 additions and 7 deletions

View File

@ -15,8 +15,11 @@
<br class="hidden md:inline" /> <br class="hidden md:inline" />
<span class="text-indigo-600">Ourworld Mkusanyiko</span> <span class="text-indigo-600">Ourworld Mkusanyiko</span>
</h2> </h2>
<div flex>
<div class="bg-gray-800 text-white rounded text-sm w-fit font-medium p-1 mt-2 sm:mt-4">26 October 2022 @@6PM</div>
</div>
<p class="mt-3 text- text-gray-500 sm:mt-5 sm:text-xl lg:text-lg xl:text-xl"> <p class="mt-3 text- text-gray-500 sm:mt-5 sm:text-xl lg:text-lg xl:text-xl">
Located at Mbweni Ruins, Jungle Paradise Resort - Ourworld Mkusanyiko will bring together Africa's emerging leaders that shape the regenerative, inclusive and empowering digital future of Africa. </p> Join us at Mbweni Ruins, Jungle Paradise Resort to celebrate - with music, artists & food - our collective effort to pave the way towards a regenerative, inclusive and empowering digital future in Africa. Shuttles available from conference center.
<div class="mt-3 sm:mt-5 sm:max-w-lg sm:mx-auto sm:text-center lg:text-left lg:mx-0"> <div class="mt-3 sm:mt-5 sm:max-w-lg sm:mx-auto sm:text-center lg:text-left lg:mx-0">
<form hx-post="/register" class="mt-3 sm:flex flex-col"> <form hx-post="/register" class="mt-3 sm:flex flex-col">
<div> <div>
@ -62,7 +65,7 @@
<label for="settings-option-1" class="ml-3 flex flex-col cursor-pointer"> <label for="settings-option-1" class="ml-3 flex flex-col cursor-pointer">
<!-- On: "text-indigo-900", Off: "text-gray-900" --> <!-- On: "text-indigo-900", Off: "text-gray-900" -->
<span class="block text-sm leading-5 font-normal"> <span class="block text-sm leading-5 font-normal">
I want to receive communication about Ourworld. I want to receive communication on Ourworld.
</span> </span>
</label> </label>
</div> </div>

56
templates/emailreq.html Normal file
View File

@ -0,0 +1,56 @@
<form hx-post="/register" class="mt-3 sm:flex flex-col">
<div>
<div class="md:flex">
<div class="flex-col md:mr-2">
<label for="name" class="block text-sm font-medium leading-5 text-gray-700">Name</label>
<input id="name" name="name" aria-label="Name" class="appearance-none block w-full mt-1 px-3 py-3 border border-gray-300 text-base leading-6 rounded-md placeholder-gray-500 shadow-sm focus:outline-none focus:placeholder-gray-400 focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:flex-1" placeholder="Name Surname" />
</div>
<div class="md:ml-2">
<label for="company_website" class="block text-sm font-medium leading-5 text-gray-700">Organization Website</label>
<div class="mt-1 relative rounded-md shadow-sm">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<span class="text-gray-500 sm:text-base sm:leading-5">
http://
</span>
</div>
<input id="company_website" name="org_website" class="form-input pl-16 sm:pl-14 appearance-none block w-full px-3 py-3 border border-gray-300 text-base leading-6 rounded-md placeholder-gray-500 shadow-sm focus:outline-none focus:placeholder-gray-400 focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:flex-1" placeholder="www.example.com" />
</div>
</div>
</div>
</div>
<div class="mt-3 sm:flex">
<input aria-label="Email" name="email" class="appearance-none block w-full px-3 py-3 border border-gray-300 text-base leading-6 rounded-md placeholder-gray-500 shadow-sm focus:outline-none focus:placeholder-gray-400 focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:flex-1" placeholder="Enter your email" />
<button type="submit" class="mt-3 w-full px-6 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-gray-800 shadow-sm hover:bg-gray-700 focus:outline-none focus:border-gray-900 focus:shadow-outline-gray active:bg-gray-900 transition duration-150 ease-in-out sm:mt-0 sm:ml-3 sm:flex-shrink-0 sm:inline-flex sm:items-center sm:w-auto">
Register
</button>
</div>
<div class="relative mt-4 flex">
<div class="flex items-center h-5">
<input id="settings-option-0" name="plus_one" type="checkbox" class="form-radio h-4 w-4 text-indigo-600 transition duration-150 ease-in-out cursor-pointer" />
</div>
<label for="settings-option-0" class="ml-3 flex flex-col cursor-pointer">
<!-- On: "text-indigo-900", Off: "text-gray-900" -->
<span class="block text-sm leading-5 font-normal">
I want to register a plus one to join the event.
</span>
</label>
</div>
<div class="relative mt-4 flex">
<div class="flex items-center h-5">
<input id="settings-option-1" name="receive_communication" type="checkbox" class="form-radio h-4 w-4 text-indigo-600 transition duration-150 ease-in-out cursor-pointer" checked />
</div>
<label for="settings-option-1" class="ml-3 flex flex-col cursor-pointer">
<!-- On: "text-indigo-900", Off: "text-gray-900" -->
<span class="block text-sm leading-5 font-normal">
I want to receive communication and e-mails about Ourworld.
</span>
</label>
</div>
<div class="relative pt-6 text-red-600 font-medium">
Email is required to registered for event. Please try again.
</div>
</form>

56
templates/invalid.html Normal file
View File

@ -0,0 +1,56 @@
<form hx-post="/register" class="mt-3 sm:flex flex-col">
<div>
<div class="md:flex">
<div class="flex-col md:mr-2">
<label for="name" class="block text-sm font-medium leading-5 text-gray-700">Name</label>
<input id="name" name="name" aria-label="Name" class="appearance-none block w-full mt-1 px-3 py-3 border border-gray-300 text-base leading-6 rounded-md placeholder-gray-500 shadow-sm focus:outline-none focus:placeholder-gray-400 focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:flex-1" placeholder="Name Surname" />
</div>
<div class="md:ml-2">
<label for="company_website" class="block text-sm font-medium leading-5 text-gray-700">Organization Website</label>
<div class="mt-1 relative rounded-md shadow-sm">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<span class="text-gray-500 sm:text-base sm:leading-5">
http://
</span>
</div>
<input id="company_website" name="org_website" class="form-input pl-16 sm:pl-14 appearance-none block w-full px-3 py-3 border border-gray-300 text-base leading-6 rounded-md placeholder-gray-500 shadow-sm focus:outline-none focus:placeholder-gray-400 focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:flex-1" placeholder="www.example.com" />
</div>
</div>
</div>
</div>
<div class="mt-3 sm:flex">
<input aria-label="Email" name="email" class="appearance-none block w-full px-3 py-3 border border-gray-300 text-base leading-6 rounded-md placeholder-gray-500 shadow-sm focus:outline-none focus:placeholder-gray-400 focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:flex-1" placeholder="Enter your email" />
<button type="submit" class="mt-3 w-full px-6 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-gray-800 shadow-sm hover:bg-gray-700 focus:outline-none focus:border-gray-900 focus:shadow-outline-gray active:bg-gray-900 transition duration-150 ease-in-out sm:mt-0 sm:ml-3 sm:flex-shrink-0 sm:inline-flex sm:items-center sm:w-auto">
Register
</button>
</div>
<div class="relative mt-4 flex">
<div class="flex items-center h-5">
<input id="settings-option-0" name="plus_one" type="checkbox" class="form-radio h-4 w-4 text-indigo-600 transition duration-150 ease-in-out cursor-pointer" />
</div>
<label for="settings-option-0" class="ml-3 flex flex-col cursor-pointer">
<!-- On: "text-indigo-900", Off: "text-gray-900" -->
<span class="block text-sm leading-5 font-normal">
I want to register a plus one to join the event.
</span>
</label>
</div>
<div class="relative mt-4 flex">
<div class="flex items-center h-5">
<input id="settings-option-1" name="receive_communication" type="checkbox" class="form-radio h-4 w-4 text-indigo-600 transition duration-150 ease-in-out cursor-pointer" checked />
</div>
<label for="settings-option-1" class="ml-3 flex flex-col cursor-pointer">
<!-- On: "text-indigo-900", Off: "text-gray-900" -->
<span class="block text-sm leading-5 font-normal">
I want to receive communication and e-mails about Ourworld.
</span>
</label>
</div>
<div class="relative pt-6 text-red-600 font-medium">
You've entered invalid input. Please try again.
</div>
</form>

View File

@ -43,12 +43,27 @@ pub fn (mut app App) full() vweb.Result {
return $vweb.html() return $vweb.html()
} }
pub fn (mut app App) emailreq() vweb.Result {
return $vweb.html()
}
pub fn (mut app App) invalid() vweb.Result {
return $vweb.html()
}
['/register'; post] ['/register'; post]
pub fn (mut app App) register(name string, email string, org_website string, plus_one string, receive_communication string) vweb.Result { pub fn (mut app App) register(name string, email string, org_website string, plus_one string, receive_communication string) vweb.Result {
files := os.ls('registrations') or { [] } files := os.ls('registrations') or { [] }
// if files.len > 1000 { if files.len > 1000 {
// return full() return app.full()
// } }
if email.len < 5 && !email.contains('@') && !email.contains('.') {
return app.emailreq()
}
if email.len > 100 || name.len > 100 || org_website.len > 200 || email.contains('<script>') || name.contains('<script>') || org_website.contains('<script>'){
return app.invalid()
}
registration := Registration { registration := Registration {
name: name, name: name,
email: email, email: email,