【问题标题】:Yesod: Non-exhaustive patterns in function isAuthorizedYesod:函数 isAuthorized 中的非详尽模式
【发布时间】:2017-03-29 17:50:50
【问题描述】:

在一个 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]

我该如何解决?

【问题讨论】:

    标签: haskell authorization yesod


    【解决方案1】:

    需要修改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
    

    【讨论】:

      猜你喜欢
      • 2021-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多