yesodスキャフォールドを使用しています。settings.ymlファイルから値を取得する方法に少し苦労しています。
settings.ymlファイルの関連部分は次のようになります。
Default: &defaults
host: "*4" # any IPv4 host
port: 3000
approot: "http://localhost:3000"
admins: ["someEmail@gmail.com", "someOtherEmail@gmail.com"]
そして、Foundation.hsファイルに、ユーザーの電子メール(googleauthを使用)が事前に指定された電子メールと一致するかどうかを確認する方法があります。
admins = ["someEmail@gmail.com", "someOtherEmail@gmail.com"]
isAdmin (Just (Entity _ user)) | elem (userIdent user) admins = Authorized
| otherwise = AuthenticationRequired
isAdmin Nothing = AuthenticationRequired
私の目標は、admins関数をsettings.ymlファイルの関数に置き換えることです。
これを行う上での助けは大歓迎です!
編集:
さて、私は次の方法で新しく作られた「余分な」をフェッチするところまで来ました、
admins = do
madmins <- extraAdmins getExtra
case madmins of
Nothing -> return Nothing
Just admins -> return admins
しかし、GHCはこれを私に投げかけます、
Foundation.hs:161:28:
Couldn't match expected type `Extra'
with actual type `Handler Extra'
In the first argument of `extraAdmins', namely `getExtra'
In a stmt of a 'do' block: madmins <- extraAdmins getExtra
In the expression:
do { madmins <- extraAdmins getExtra;
case madmins of {
Nothing -> return Nothing
Just admins -> return admins } }
ハンドラーエクストラからエクストラに変換する方法はありますか、それとも単に間違った方法で行っていますか?