Authorizationのしかた
雪が降った後でヤバいのですが、YesodでログインしたあとのAuthorization(認可)のやり方を調べたのでメモ。簡単に言ってしまうと、YesodクラスのisAuthorized関数をいじると出来ちゃう、具体的には
* Foundation.hsを修正
instance Yesod App where -- Controls the base of generated URLs. For more information on modifying, -- see: https://github.com/yesodweb/yesod/wiki/Overriding-approot approot = ApprootMaster $ appRoot . appSettings ... ... ... -- Default to Authorized for now. -- ここをisLoginedで書き換え isAuthorized _ _ = isLogined ... ... -- ログインしていたらAuthorizedを返す isLogined::HandlerT App IO AuthResult isLogined = do mu <- maybeAuthId return $ case mu of Nothing -> AuthenticationRequired Just _ -> AuthorizedisAuthorizedの引数を指定すれば対応するURLにAuthorizationがかかるらしい(適当ですいません)、なるほどぉ
0 件のコメント:
コメントを投稿