Yesod:函数中的非详尽模式是授权的

时间:2017-03-29 09:48:50

标签: haskell authorization yesod

在Yesod脚手架项目中,我添加了一个新路由和一个新处理程序。

我的错误如下:

29/Mar/2017:11:25:22 +0200 [Error#yesod-core] Foundation.hs:(137,5)-(144,45): Non-exhaustive patterns in function isAuthorized
 @(yesod-core-1.4.32-6HthMZNCl0sEMRz6GJ4QO1:Yesod.Core.Class.Yesod ./Yesod/Core/Class/Yesod.hs:693:5)
29/Mar/2017:11:25:22 +0200 [Debug#SQL] SELECT `ident`,`password` FROM `user` WHERE `id`=? ; [PersistInt64 1]

我该如何解决?

1 个答案:

答案 0 :(得分:6)

有必要修改Foundation.hs文件,将新路由添加到授权中:

-- Routes not requiring authentication.
isAuthorized (AuthR _) _ = return Authorized
isAuthorized CommentR _ = return Authorized
isAuthorized HomeR _ = return Authorized
isAuthorized FaviconR _ = return Authorized
isAuthorized RobotsR _ = return Authorized
isAuthorized (StaticR _) _ = return Authorized
isAuthorized TestR _ = return Authorized

isAuthorized ProfileR _ = isAuthenticated