Remove unused Profile controller, from the scaffolding
This commit is contained in:
parent
0a230e7644
commit
a2a0ec5127
5 changed files with 2 additions and 72 deletions
|
@ -5,5 +5,3 @@
|
|||
/robots.txt RobotsR GET
|
||||
|
||||
/ HomeR GET
|
||||
|
||||
/profile ProfileR GET
|
||||
|
|
|
@ -49,7 +49,6 @@ import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet,
|
|||
-- Don't forget to add new modules to your cabal file!
|
||||
import Handler.Common
|
||||
import Handler.Home
|
||||
import Handler.Profile
|
||||
|
||||
-- This line actually creates our YesodDispatch instance. It is the second half
|
||||
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
||||
|
|
|
@ -100,35 +100,14 @@ instance Yesod App where
|
|||
master <- getYesod
|
||||
mmsg <- getMessage
|
||||
|
||||
muser <- maybeAuthPair
|
||||
-- muser <- maybeAuthPair
|
||||
mcurrentRoute <- getCurrentRoute
|
||||
|
||||
-- Get the breadcrumbs, as defined in the YesodBreadcrumbs instance.
|
||||
(title, parents) <- breadcrumbs
|
||||
|
||||
-- Define the menu items of the header.
|
||||
let menuItems =
|
||||
[ NavbarLeft $ MenuItem
|
||||
{ menuItemLabel = "Home"
|
||||
, menuItemRoute = HomeR
|
||||
, menuItemAccessCallback = True
|
||||
}
|
||||
, NavbarLeft $ MenuItem
|
||||
{ menuItemLabel = "Profile"
|
||||
, menuItemRoute = ProfileR
|
||||
, menuItemAccessCallback = isJust muser
|
||||
}
|
||||
, NavbarRight $ MenuItem
|
||||
{ menuItemLabel = "Login"
|
||||
, menuItemRoute = AuthR LoginR
|
||||
, menuItemAccessCallback = isNothing muser
|
||||
}
|
||||
, NavbarRight $ MenuItem
|
||||
{ menuItemLabel = "Logout"
|
||||
, menuItemRoute = AuthR LogoutR
|
||||
, menuItemAccessCallback = isJust muser
|
||||
}
|
||||
]
|
||||
let menuItems = []
|
||||
|
||||
let navbarLeftMenuItems = [x | NavbarLeft x <- menuItems]
|
||||
let navbarRightMenuItems = [x | NavbarRight x <- menuItems]
|
||||
|
@ -155,8 +134,6 @@ instance Yesod App where
|
|||
isAuthorized RobotsR _ = return Authorized
|
||||
isAuthorized (StaticR _) _ = return Authorized
|
||||
|
||||
isAuthorized ProfileR _ = isAuthenticated
|
||||
|
||||
-- This function creates static content files in the static folder
|
||||
-- and names them based on a hash of their content. This allows
|
||||
-- expiration dates to be set far in the future without worry of
|
||||
|
@ -189,7 +166,6 @@ instance Yesod App where
|
|||
instance YesodBreadcrumbs App where
|
||||
breadcrumb HomeR = return ("Home", Nothing)
|
||||
breadcrumb (AuthR _) = return ("Login", Just HomeR)
|
||||
breadcrumb ProfileR = return ("Profile", Just HomeR)
|
||||
breadcrumb _ = return ("home", Nothing)
|
||||
|
||||
-- How to run database actions.
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
module Handler.Profile where
|
||||
|
||||
import Import
|
||||
|
||||
getProfileR :: Handler Html
|
||||
getProfileR = do
|
||||
(_, user) <- requireAuthPair
|
||||
defaultLayout $ do
|
||||
setTitle . toHtml $ userIdent user <> "'s User page"
|
||||
$(widgetFile "profile")
|
|
@ -1,28 +0,0 @@
|
|||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Handler.ProfileSpec (spec) where
|
||||
|
||||
import TestImport
|
||||
|
||||
spec :: Spec
|
||||
spec = withApp $ do
|
||||
|
||||
describe "Profile page" $ do
|
||||
it "asserts no access to my-account for anonymous users" $ do
|
||||
get ProfileR
|
||||
statusIs 403
|
||||
|
||||
it "asserts access to my-account for authenticated users" $ do
|
||||
userEntity <- createUser "foo"
|
||||
authenticateAs userEntity
|
||||
|
||||
get ProfileR
|
||||
statusIs 200
|
||||
|
||||
it "asserts user's information is shown" $ do
|
||||
userEntity <- createUser "bar"
|
||||
authenticateAs userEntity
|
||||
|
||||
get ProfileR
|
||||
let (Entity _ user) = userEntity
|
||||
htmlAnyContain ".username" . unpack $ userIdent user
|
Loading…
Reference in a new issue