Clean up user entity - remove unused fields, adjust order

This commit is contained in:
Danielle McLean 2017-10-03 14:52:23 +11:00
parent 4023b17e85
commit a070ceef3c
Signed by: 00dani
GPG key ID: 3844A6973C6058F1
4 changed files with 10 additions and 26 deletions

View file

@ -1,22 +1,17 @@
User User
ident Text sqltype=varchar(255) username Text maxlen=190
fullName Text sqltype=varchar(500) fullName Text maxlen=500
email Text sqltype=varchar(255) email Text maxlen=190
note Text note Text
password Text Maybe sqltype=varchar(255) default=NULL UniqueUsername username
UniqueUser ident UniqueEmail email
deriving Typeable deriving Typeable
Comment json -- Adding "json" causes ToJSON and FromJSON instances to be derived.
message Text sqltype=varchar(255)
userId UserId Maybe default=NULL
deriving Eq
deriving Show
Site Site
icon Text sqltype=varchar(255) icon Text sqltype=varchar(255)
url Text sqltype=varchar(255) url Text sqltype=varchar(255)
Profile Profile
userId UserId userId UserId
siteId SiteId siteId SiteId
username Text sqltype=varchar(255) username Text sqltype=varchar(255)
-- By default this file is used in Model.hs (which is imported by Foundation.hs)

View file

@ -188,15 +188,14 @@ instance YesodAuth App where
redirectToReferer _ = True redirectToReferer _ = True
authenticate creds = runDB $ do authenticate creds = runDB $ do
x <- getBy $ UniqueUser $ credsIdent creds x <- getBy . UniqueUsername $ credsIdent creds
case x of case x of
Just (Entity uid _) -> return $ Authenticated uid Just (Entity uid _) -> return $ Authenticated uid
Nothing -> Authenticated <$> insert User Nothing -> Authenticated <$> insert User
{ userIdent = credsIdent creds { userUsername = credsIdent creds
, userFullName = "" , userFullName = ""
, userEmail = "" , userEmail = ""
, userNote = "" , userNote = ""
, userPassword = Nothing
} }
-- You can add other plugins like Google Email, email or OAuth here -- You can add other plugins like Google Email, email or OAuth here

View file

@ -10,5 +10,5 @@ import Widget.Hcard (hcard)
getHomeR :: Handler Html getHomeR :: Handler Html
getHomeR = do getHomeR = do
user <- runDB . getBy404 $ UniqueUser "dani" user <- runDB . getBy404 $ UniqueUsername "dani"
defaultLayout $(widgetFile "home") defaultLayout $(widgetFile "home")

View file

@ -1,10 +0,0 @@
<div .ui.container>
<h1>
Access granted!
<p>
This page is protected and access is allowed only for authenticated users.
<p>
Your data is protected with us <strong><span class="username">#{userIdent user}</span></strong>!