diff --git a/Handler/Profile.hs b/Handler/Profile.hs index 29cb69a..f313bc5 100644 --- a/Handler/Profile.hs +++ b/Handler/Profile.hs @@ -18,3 +18,13 @@ getProfileR ownerId = do return False defaultLayout $ do $(widgetFile "profile") + +getUserR :: Text -> Handler Html +getUserR ownerName = do + tempOwner <- runDB $ selectFirst [UserName ==. ownerName] [] + case tempOwner of + Just (Entity ownerId owner) -> + getProfileR ownerId + Nothing -> do + setMessage "This user does not exist" + redirect $ HomeR diff --git a/config/routes b/config/routes index fa54457..4a37c02 100644 --- a/config/routes +++ b/config/routes @@ -8,7 +8,8 @@ /login LoginR GET POST /logout LogoutR GET /activate/#Text ActivateR GET -/user/#UserId ProfileR GET +/profile/#UserId ProfileR GET +/user/#Text UserR GET /upload UploadR GET POST /newalbum NewAlbumR GET POST /album/#AlbumId AlbumR GET