From c0a86c3f5b9d364a751c39161fece9248d63b8d0 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Fri, 19 Feb 2016 04:10:42 +0000 Subject: [PATCH] Add user registration form view, still no-op --- config/routes | 27 ++++++++++++++++++--------- src/Handler/Person.hs | 31 +++++++++++++++++++++++++++++++ templates/person-new.hamlet | 21 +++++++++++++++++++++ 3 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 templates/person-new.hamlet diff --git a/config/routes b/config/routes index c1ead1e..d473a36 100644 --- a/config/routes +++ b/config/routes @@ -16,23 +16,32 @@ -- Yesod misc -- ---------------------------------------------------------------------------- -/static StaticR Static appStatic -/favicon.ico FaviconR GET -/robots.txt RobotsR GET +/static StaticR Static appStatic +/favicon.ico FaviconR GET +/robots.txt RobotsR GET -- ---------------------------------------------------------------------------- -- User signup and login -- ---------------------------------------------------------------------------- -/auth AuthR Auth getAuth +/auth AuthR Auth getAuth -- ---------------------------------------------------------------------------- -- Everything else... -- ---------------------------------------------------------------------------- -/ HomeR GET +/ HomeR GET -/u PeopleR GET -/u/#Text PersonR GET -/u/#Text/p ProjectsR GET -/u/#Text/p/#Text ProjectR GET +/u PeopleR GET -- POST +/u/!new PersonNewR GET +/u/#Text PersonR GET + +/u/#Text/p ProjectsR GET +/u/#Text/p/#Text ProjectR GET + +-- /u/#Text/p/#Text/r ReposR GET +-- /u/#Text/p/#Text/r/#Text RepoR GET +-- /u/#Text/p/#Text/t TicketsR GET +-- /u/#Text/p/#Text/t/#TicketId TicketR GET +-- /u/#Text/p/#Text/w WikiR GET +-- /u/#Text/p/#Text/w/+Texts WikiPageR GET diff --git a/src/Handler/Person.hs b/src/Handler/Person.hs index 3149c13..0e59915 100644 --- a/src/Handler/Person.hs +++ b/src/Handler/Person.hs @@ -15,6 +15,7 @@ module Handler.Person ( getPeopleR + , getPersonNewR , getPersonR ) where @@ -27,6 +28,21 @@ import Database.Esqueleto --import Model --import Yesod.Core (Handler) +data PersonNew = PersonNew + { uLogin :: Text + , uPass :: Text + , uPass' :: Text + , uEmail :: Maybe Text + } + +formPersonNew :: Form PersonNew +formPersonNew = renderDivs $ PersonNew + <$> areq textField "Username" Nothing + <*> areq passwordField "Password" Nothing + <*> areq passwordField "Repeat password" Nothing + <*> aopt emailField "E-mail" Nothing + +-- | Get list of users getPeopleR :: Handler Html getPeopleR = do people <- runDB $ select $ from $ \ (sharer, person) -> do @@ -37,6 +53,21 @@ getPeopleR = do setTitle "Vervis > People" $(widgetFile "people") +-- | Create new user +--postPeopleR :: Handler Html +--postPeopleR = + +getPersonNewR :: Handler Html +getPersonNewR = do + mpid <- maybeAuthId + if isJust mpid + then redirect HomeR + else do + ((_result, widget), enctype) <- runFormPost formPersonNew + defaultLayout $ do + setTitle "Vervis > People > New" + $(widgetFile "person-new") + getPersonR :: Text -> Handler Html getPersonR ident = do people <- runDB $ select $ from $ \ (sharer, person) -> do diff --git a/templates/person-new.hamlet b/templates/person-new.hamlet new file mode 100644 index 0000000..1d0da68 --- /dev/null +++ b/templates/person-new.hamlet @@ -0,0 +1,21 @@ +$# This file is part of Vervis. +$# +$# Written in 2016 by fr33domlover . +$# +$# ♡ Copying is an act of love. Please copy, reuse and share. +$# +$# The author(s) have dedicated all copyright and related and neighboring +$# rights to this software to the public domain worldwide. This software is +$# distributed without any warranty. +$# +$# You should have received a copy of the CC0 Public Domain Dedication along +$# with this software. If not, see +$# . + +

Vervis > People > New + +Enter your details and click on "Submit" to create a new user account. + +
+ ^{widget} +