Clean up user entity - remove unused fields, adjust order
This commit is contained in:
parent
4023b17e85
commit
a070ceef3c
4 changed files with 10 additions and 26 deletions
|
@ -1,22 +1,17 @@
|
|||
User
|
||||
ident Text sqltype=varchar(255)
|
||||
fullName Text sqltype=varchar(500)
|
||||
email Text sqltype=varchar(255)
|
||||
username Text maxlen=190
|
||||
fullName Text maxlen=500
|
||||
email Text maxlen=190
|
||||
note Text
|
||||
password Text Maybe sqltype=varchar(255) default=NULL
|
||||
UniqueUser ident
|
||||
UniqueUsername username
|
||||
UniqueEmail email
|
||||
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
|
||||
icon Text sqltype=varchar(255)
|
||||
url Text sqltype=varchar(255)
|
||||
|
||||
Profile
|
||||
userId UserId
|
||||
siteId SiteId
|
||||
username Text sqltype=varchar(255)
|
||||
|
||||
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
|
||||
|
|
|
@ -188,15 +188,14 @@ instance YesodAuth App where
|
|||
redirectToReferer _ = True
|
||||
|
||||
authenticate creds = runDB $ do
|
||||
x <- getBy $ UniqueUser $ credsIdent creds
|
||||
x <- getBy . UniqueUsername $ credsIdent creds
|
||||
case x of
|
||||
Just (Entity uid _) -> return $ Authenticated uid
|
||||
Nothing -> Authenticated <$> insert User
|
||||
{ userIdent = credsIdent creds
|
||||
{ userUsername = credsIdent creds
|
||||
, userFullName = ""
|
||||
, userEmail = ""
|
||||
, userNote = ""
|
||||
, userPassword = Nothing
|
||||
}
|
||||
|
||||
-- You can add other plugins like Google Email, email or OAuth here
|
||||
|
|
|
@ -10,5 +10,5 @@ import Widget.Hcard (hcard)
|
|||
|
||||
getHomeR :: Handler Html
|
||||
getHomeR = do
|
||||
user <- runDB . getBy404 $ UniqueUser "dani"
|
||||
user <- runDB . getBy404 $ UniqueUsername "dani"
|
||||
defaultLayout $(widgetFile "home")
|
||||
|
|
|
@ -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>!
|
Loading…
Reference in a new issue