clckwrks 0.27.2 → 0.28.0
raw patch · 11 files changed
+119/−60 lines, 11 filesdep ~happstack-authenticatePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: happstack-authenticate
API changes (from Hackage documentation)
- Clckwrks.Authenticate.Monad: AcidStateAuthenticate :: AcidState AuthenticateState -> AcidState PasswordState -> AcidStateAuthenticate
- Clckwrks.Authenticate.Monad: data AcidStateAuthenticate
+ Clckwrks.Acid: CoreState_3 :: Maybe Text -> Maybe UACCT -> Maybe Text -> Maybe Text -> Maybe SimpleAddress -> Maybe SimpleAddress -> Maybe FilePath -> Bool -> (FilePath, Int64, Int64, Int64) -> CoreState_3
+ Clckwrks.Acid: GetBackToSiteRedirect :: GetBackToSiteRedirect
+ Clckwrks.Acid: SetBackToSiteRedirect :: Text -> SetBackToSiteRedirect
+ Clckwrks.Acid: [_coreBackToSiteRedirect] :: CoreState -> Text
+ Clckwrks.Acid: [_coreBodyPolicy_3] :: CoreState_3 -> (FilePath, Int64, Int64, Int64)
+ Clckwrks.Acid: [_coreEnableOpenId_3] :: CoreState_3 -> Bool
+ Clckwrks.Acid: [_coreFromAddress_3] :: CoreState_3 -> Maybe SimpleAddress
+ Clckwrks.Acid: [_coreLoginRedirect_3] :: CoreState_3 -> Maybe Text
+ Clckwrks.Acid: [_coreReplyToAddress_3] :: CoreState_3 -> Maybe SimpleAddress
+ Clckwrks.Acid: [_coreRootRedirect_3] :: CoreState_3 -> Maybe Text
+ Clckwrks.Acid: [_coreSendmailPath_3] :: CoreState_3 -> Maybe FilePath
+ Clckwrks.Acid: [_coreSiteName_3] :: CoreState_3 -> Maybe Text
+ Clckwrks.Acid: [_coreUACCT_3] :: CoreState_3 -> Maybe UACCT
+ Clckwrks.Acid: coreBackToSiteRedirect :: Lens' CoreState Text
+ Clckwrks.Acid: data CoreState_3
+ Clckwrks.Acid: data GetBackToSiteRedirect
+ Clckwrks.Acid: getBackToSiteRedirect :: Query CoreState Text
+ Clckwrks.Acid: instance Data.Acid.Common.QueryEvent Clckwrks.Acid.GetBackToSiteRedirect
+ Clckwrks.Acid: instance Data.Acid.Common.UpdateEvent Clckwrks.Acid.SetBackToSiteRedirect
+ Clckwrks.Acid: instance Data.Acid.Core.Method Clckwrks.Acid.GetBackToSiteRedirect
+ Clckwrks.Acid: instance Data.Acid.Core.Method Clckwrks.Acid.SetBackToSiteRedirect
+ Clckwrks.Acid: instance Data.Data.Data Clckwrks.Acid.CoreState_3
+ Clckwrks.Acid: instance Data.SafeCopy.SafeCopy.Migrate Clckwrks.Acid.CoreState_3
+ Clckwrks.Acid: instance Data.SafeCopy.SafeCopy.SafeCopy Clckwrks.Acid.CoreState_3
+ Clckwrks.Acid: instance Data.SafeCopy.SafeCopy.SafeCopy Clckwrks.Acid.GetBackToSiteRedirect
+ Clckwrks.Acid: instance Data.SafeCopy.SafeCopy.SafeCopy Clckwrks.Acid.SetBackToSiteRedirect
+ Clckwrks.Acid: instance GHC.Classes.Eq Clckwrks.Acid.CoreState_3
+ Clckwrks.Acid: instance GHC.Show.Show Clckwrks.Acid.CoreState_3
+ Clckwrks.Acid: newtype SetBackToSiteRedirect
+ Clckwrks.Acid: setBackToSiteRedirect :: Text -> Update CoreState ()
+ Clckwrks.Authenticate.API: setCreateUserCallback :: ClckPlugins -> Maybe (User -> IO ()) -> IO ()
+ Clckwrks.Authenticate.Monad: AuthenticatePluginState :: AcidState AuthenticateState -> AcidState PasswordState -> TVar AuthenticateConfig -> TVar PasswordConfig -> AuthenticatePluginState
+ Clckwrks.Authenticate.Monad: [apsAuthenticateConfigTV] :: AuthenticatePluginState -> TVar AuthenticateConfig
+ Clckwrks.Authenticate.Monad: [apsPasswordConfigTV] :: AuthenticatePluginState -> TVar PasswordConfig
+ Clckwrks.Authenticate.Monad: data AuthenticatePluginState
- Clckwrks.Acid: CoreState :: Maybe Text -> Maybe UACCT -> Maybe Text -> Maybe Text -> Maybe SimpleAddress -> Maybe SimpleAddress -> Maybe FilePath -> Bool -> (FilePath, Int64, Int64, Int64) -> CoreState
+ Clckwrks.Acid: CoreState :: Maybe Text -> Maybe UACCT -> Maybe Text -> Maybe Text -> Text -> Maybe SimpleAddress -> Maybe SimpleAddress -> Maybe FilePath -> Bool -> (FilePath, Int64, Int64, Int64) -> CoreState
- Clckwrks.Authenticate.Monad: [acidStateAuthenticate] :: AcidStateAuthenticate -> AcidState AuthenticateState
+ Clckwrks.Authenticate.Monad: [acidStateAuthenticate] :: AuthenticatePluginState -> AcidState AuthenticateState
- Clckwrks.Authenticate.Monad: [acidStatePassword] :: AcidStateAuthenticate -> AcidState PasswordState
+ Clckwrks.Authenticate.Monad: [acidStatePassword] :: AuthenticatePluginState -> AcidState PasswordState
Files
- Clckwrks/Acid.hs +37/−3
- Clckwrks/Admin/EditSettings.hs +10/−4
- Clckwrks/Admin/Template.hs +3/−2
- Clckwrks/Authenticate/API.hs +18/−9
- Clckwrks/Authenticate/Monad.hs +13/−9
- Clckwrks/Authenticate/Plugin.hs +13/−8
- Clckwrks/Monad.hs +3/−3
- Clckwrks/ProfileData/EditNewProfileData.hs +3/−3
- Clckwrks/ProfileData/EditProfileData.hs +5/−5
- Clckwrks/ProfileData/EditProfileDataFor.hs +12/−12
- clckwrks.cabal +2/−2
Clckwrks/Acid.hs view
@@ -26,6 +26,7 @@ import Data.Maybe (fromMaybe) import Data.SafeCopy (Migrate(..), base, deriveSafeCopy, extension) import Data.Text (Text)+import qualified Data.Text as Text import Happstack.Authenticate.Core (AuthenticateState, SimpleAddress(..)) import Happstack.Authenticate.Password.Core (PasswordState) import Prelude hiding (catch)@@ -85,11 +86,33 @@ -- | 'CoreState' holds some values that are required by the core -- itself, or which are useful enough to be shared with numerous -- plugins/themes.+data CoreState_3 = CoreState_3+ { _coreSiteName_3 :: Maybe Text+ , _coreUACCT_3 :: Maybe UACCT -- ^ Google Account UAACT+ , _coreRootRedirect_3 :: Maybe Text+ , _coreLoginRedirect_3 :: Maybe Text+ , _coreFromAddress_3 :: Maybe SimpleAddress+ , _coreReplyToAddress_3 :: Maybe SimpleAddress+ , _coreSendmailPath_3 :: Maybe FilePath+ , _coreEnableOpenId_3 :: Bool -- ^ allow OpenId authentication+ , _coreBodyPolicy_3 :: (FilePath, Int64, Int64, Int64) -- ^ (temp directory for uploads, maxDisk, maxRAM, maxHeader)+ }+ deriving (Eq, Data, Typeable, Show)+$(deriveSafeCopy 3 'extension ''CoreState_3)++instance Migrate CoreState_3 where+ type MigrateFrom CoreState_3 = CoreState_2+ migrate (CoreState_2 sn ua rr lr fa rta smp eo) = CoreState_3 sn ua rr lr fa rta smp eo ("/tmp/", (10 * 10^6), (1 * 10^6), (1 * 10^6))++-- | 'CoreState' holds some values that are required by the core+-- itself, or which are useful enough to be shared with numerous+-- plugins/themes. data CoreState = CoreState { _coreSiteName :: Maybe Text , _coreUACCT :: Maybe UACCT -- ^ Google Account UAACT , _coreRootRedirect :: Maybe Text , _coreLoginRedirect :: Maybe Text+ , _coreBackToSiteRedirect :: Text -- ^ where 'Back To <sitename>' link in settings panel should go , _coreFromAddress :: Maybe SimpleAddress , _coreReplyToAddress :: Maybe SimpleAddress , _coreSendmailPath :: Maybe FilePath@@ -97,13 +120,13 @@ , _coreBodyPolicy :: (FilePath, Int64, Int64, Int64) -- ^ (temp directory for uploads, maxDisk, maxRAM, maxHeader) } deriving (Eq, Data, Typeable, Show)-$(deriveSafeCopy 3 'extension ''CoreState)+$(deriveSafeCopy 4 'extension ''CoreState) makeLenses ''CoreState instance Migrate CoreState where- type MigrateFrom CoreState = CoreState_2- migrate (CoreState_2 sn ua rr lr fa rta smp eo) = CoreState sn ua rr lr fa rta smp eo ("/tmp/", (10 * 10^6), (1 * 10^6), (1 * 10^6))+ type MigrateFrom CoreState = CoreState_3+ migrate (CoreState_3 sn ua rr lr fa rta smp eo bp) = CoreState sn ua rr lr (Text.pack "/") fa rta smp eo bp initialCoreState :: CoreState initialCoreState = CoreState@@ -111,6 +134,7 @@ , _coreUACCT = Nothing , _coreRootRedirect = Nothing , _coreLoginRedirect = Nothing+ , _coreBackToSiteRedirect = (Text.pack "/") , _coreFromAddress = Nothing , _coreReplyToAddress = Nothing , _coreSendmailPath = Nothing@@ -138,6 +162,14 @@ getRootRedirect :: Query CoreState (Maybe Text) getRootRedirect = view coreRootRedirect +-- | get the path that 'Back To Site' should go to+getBackToSiteRedirect :: Query CoreState Text+getBackToSiteRedirect = view coreBackToSiteRedirect++-- | set the path that 'Back To Site' should go to+setBackToSiteRedirect :: Text -> Update CoreState ()+setBackToSiteRedirect path = coreBackToSiteRedirect .= path+ -- | set the path that @/@ should redirect to setRootRedirect :: Maybe Text -> Update CoreState () setRootRedirect path = coreRootRedirect .= path@@ -203,6 +235,8 @@ , 'setUACCT , 'getRootRedirect , 'setRootRedirect+ , 'getBackToSiteRedirect+ , 'setBackToSiteRedirect , 'getLoginRedirect , 'setLoginRedirect , 'getBodyPolicy
Clckwrks/Admin/EditSettings.hs view
@@ -3,7 +3,7 @@ module Clckwrks.Admin.EditSettings where import Clckwrks hiding (transform)-import Clckwrks.Acid (GetUACCT(..), SetUACCT(..), coreSiteName, coreUACCT, coreRootRedirect, coreLoginRedirect)+import Clckwrks.Acid (GetUACCT(..), SetUACCT(..), coreSiteName, coreUACCT, coreRootRedirect, coreLoginRedirect, coreBackToSiteRedirect) import Clckwrks.Admin.Template (template) import Control.Lens ((&), (.~)) import Data.Maybe (fromMaybe)@@ -39,7 +39,7 @@ fieldset $ (modifyCoreState <$> (divControlGroup $- (labelText "site name" `setAttrs` [("class":="control-label") :: Attr Text Text]) ++>+ (labelText "site name" `setAttrs` [("class":="control-label") :: Attr Text Text]) ++> (divControls (inputText (fromMaybe mempty _coreSiteName)) `transformEither` toMaybe))) <*> (divControlGroup $@@ -51,8 +51,13 @@ (divControls (inputText (fromMaybe mempty _coreRootRedirect)) `transformEither` toMaybe)) <*> (divControlGroup $- (labelText "after login redirect to" `setAttrs` [("class":="control-label") :: Attr Text Text]) ++>+ (labelText "Back To Site location" `setAttrs` [("class":="control-label") :: Attr Text Text]) ++>+ (divControls (inputText _coreBackToSiteRedirect)))++ <*> (divControlGroup $+ (labelText "after login redirect to" `setAttrs` [("class":="control-label") :: Attr Text Text]) ++> (divControls (inputText (fromMaybe mempty _coreLoginRedirect)) `transformEither` toMaybe))+ <*> bodyPolicyForm <* (divControlGroup $ divControls $ inputSubmit "Update" `setAttrs` [("class" := "btn") :: Attr Text Text])@@ -105,10 +110,11 @@ then Right $ Nothing else Right $ Just txt - modifyCoreState sn ua rr lr bp =+ modifyCoreState sn ua rr bts lr bp = c & coreSiteName .~ sn & coreUACCT .~ ua & coreRootRedirect .~ rr+ & coreBackToSiteRedirect .~ bts & coreLoginRedirect .~ lr & coreBodyPolicy .~ bp
Clckwrks/Admin/Template.hs view
@@ -3,7 +3,7 @@ import Control.Applicative ((<$>)) import Control.Monad.Trans (lift)-import Clckwrks.Acid (GetSiteName(..))+import Clckwrks.Acid (GetSiteName(..), GetBackToSiteRedirect(..)) import Clckwrks.Monad (ClckT(..), ClckState(adminMenus), plugins, query) import Clckwrks.URL (ClckURL(JS)) import Clckwrks.JS.URL (JSURL(..))@@ -31,6 +31,7 @@ ) => String -> headers -> body -> ClckT url m Response template title headers body = do siteName <- (fromMaybe "Your Site") <$> query GetSiteName+ backURL <- query GetBackToSiteRedirect p <- plugins <$> get ~(Just authShowURL) <- getPluginRouteFn p (pluginName authenticatePlugin) ~(Just clckShowURL) <- getPluginRouteFn p "clck"@@ -56,7 +57,7 @@ <div class="navbar"> <div class="navbar-inner"> <div class="container-fluid">- <a href="/" class="brand">Back to <% siteName %></a>+ <a href=backURL class="brand">Back to <% siteName %></a> </div> </div> </div>
Clckwrks/Authenticate/API.hs view
@@ -5,27 +5,30 @@ , getUser , getUsername , insecureUpdateUser+ , setCreateUserCallback ) where -import Clckwrks.Monad (Clck, plugins)+import Clckwrks.Authenticate.Plugin (authenticatePlugin)+import Clckwrks.Authenticate.Monad (AuthenticatePluginState(..))+import Clckwrks.Monad (Clck, ClckPlugins, plugins)+import Control.Concurrent.STM (atomically)+import Control.Concurrent.STM.TVar (modifyTVar') import Control.Monad (join) import Control.Monad.State (get) import Control.Monad.Trans (liftIO)-import Clckwrks.Authenticate.Plugin (authenticatePlugin)-import Clckwrks.Authenticate.Monad (AcidStateAuthenticate(..)) import Data.Acid as Acid (AcidState, query, update) import Data.Maybe (maybe) import Data.Monoid (mempty) import Data.Text (Text) import Data.UserId (UserId)-import Happstack.Authenticate.Core (GetUserByUserId(..), Email(..), UpdateUser(..), User(..), Username(..))-import Web.Plugins.Core (Plugin(..), When(Always), addCleanup, addHandler, addPluginState, getConfig, getPluginRouteFn, getPluginState, getPluginsSt, initPlugin)+import Happstack.Authenticate.Core (AuthenticateConfig(_createUserCallback), GetUserByUserId(..), Email(..), UpdateUser(..), User(..), Username(..))+import Web.Plugins.Core (Plugin(..), When(Always), addCleanup, addHandler, addPluginState, getConfig, getPluginRouteFn, getPluginState, getPluginsSt, initPlugin, modifyPluginState') getUser :: UserId -> Clck url (Maybe User) getUser uid = do p <- plugins <$> get- ~(Just (AcidStateAuthenticate authenticateState _)) <- getPluginState p (pluginName authenticatePlugin)- liftIO $ Acid.query authenticateState (GetUserByUserId uid)+ ~(Just aps) <- getPluginState p (pluginName authenticatePlugin)+ liftIO $ Acid.query (acidStateAuthenticate aps) (GetUserByUserId uid) -- | Update an existing 'User'. Must already have a valid 'UserId'. --@@ -34,8 +37,8 @@ insecureUpdateUser :: User -> Clck url () insecureUpdateUser user = do p <- plugins <$> get- ~(Just (AcidStateAuthenticate authenticateState _)) <- getPluginState p (pluginName authenticatePlugin)- liftIO $ Acid.update authenticateState (UpdateUser user)+ ~(Just aps) <- getPluginState p (pluginName authenticatePlugin)+ liftIO $ Acid.update (acidStateAuthenticate aps) (UpdateUser user) getUsername :: UserId -> Clck url (Maybe Username) getUsername uid =@@ -46,3 +49,9 @@ getEmail uid = do mUser <- getUser uid pure $ join $ _email <$> mUser++setCreateUserCallback :: ClckPlugins -> Maybe (User -> IO ()) -> IO ()+setCreateUserCallback p mcb =+ do ~(Just aps) <- getPluginState p (pluginName authenticatePlugin)+ liftIO $ atomically $ modifyTVar' (apsAuthenticateConfigTV aps) $ (\ac -> ac { _createUserCallback = mcb })+ pure ()
Clckwrks/Authenticate/Monad.hs view
@@ -3,28 +3,32 @@ import Clckwrks.Acid (GetAcidState(..), GetCoreState(..), GetEnableOpenId(..), acidCore, acidProfileData, coreFromAddress, coreReplyToAddress, coreSendmailPath, getAcidState) import Clckwrks.Monad+import Control.Concurrent.STM.TVar (TVar) import Control.Monad.State (get) import Control.Monad.Trans (MonadIO, lift) import Data.Acid as Acid (AcidState, query) import Data.Typeable (Typeable)-import Happstack.Authenticate.Core (AuthenticateState, AuthenticateConfig(..), getToken, tokenUser, userId, usernamePolicy)-import Happstack.Authenticate.Password.Core (PasswordState)+import Happstack.Authenticate.Core (AuthenticateState, AuthenticateConfig(..), User, getToken, tokenUser, userId, usernamePolicy)+import Happstack.Authenticate.Password.Core (PasswordConfig, PasswordState) import Web.Plugins.Core (getPluginState) -data AcidStateAuthenticate = AcidStateAuthenticate- { acidStateAuthenticate :: AcidState AuthenticateState- , acidStatePassword :: AcidState PasswordState }+data AuthenticatePluginState = AuthenticatePluginState+ { acidStateAuthenticate :: AcidState AuthenticateState+ , acidStatePassword :: AcidState PasswordState+ , apsAuthenticateConfigTV :: TVar AuthenticateConfig+ , apsPasswordConfigTV :: TVar PasswordConfig+ } deriving Typeable instance (Functor m, MonadIO m) => GetAcidState (ClckT url m) AuthenticateState where getAcidState = do p <- plugins <$> get- ~(Just (AcidStateAuthenticate authenticateState _)) <- getPluginState p "authenticate"- pure authenticateState+ ~(Just aps) <- getPluginState p "authenticate"+ pure (acidStateAuthenticate aps) instance (Functor m, MonadIO m) => GetAcidState (ClckT url m) PasswordState where getAcidState = do p <- plugins <$> get- ~(Just (AcidStateAuthenticate _ passwordState)) <- getPluginState p "authenticate"- pure passwordState+ ~(Just aps) <- getPluginState p "authenticate"+ pure (acidStatePassword aps)
Clckwrks/Authenticate/Plugin.hs view
@@ -1,9 +1,11 @@ {-# LANGUAGE DeriveDataTypeable, RecordWildCards, FlexibleContexts, Rank2Types, OverloadedStrings, MultiParamTypeClasses #-} module Clckwrks.Authenticate.Plugin where +import Control.Concurrent.STM (atomically)+import Control.Concurrent.STM.TVar (TVar, newTVar) import Clckwrks.Monad-import Clckwrks.Acid (GetAcidState(..), GetCoreState(..), GetEnableOpenId(..), acidCore, acidProfileData, coreFromAddress, coreReplyToAddress, coreSendmailPath, getAcidState)-import Clckwrks.Authenticate.Monad (AcidStateAuthenticate(..))+import Clckwrks.Acid (GetAcidState(..), GetCoreState(..), GetEnableOpenId(..), acidCore, acidProfileData, coreFromAddress, coreLoginRedirect, coreReplyToAddress, coreSendmailPath, getAcidState)+import Clckwrks.Authenticate.Monad (AuthenticatePluginState(..)) import Clckwrks.Authenticate.Route (routeAuth) import Clckwrks.Authenticate.URL (AuthURL(..)) import Clckwrks.ProfileData.Acid (HasRole(..))@@ -84,6 +86,8 @@ , _systemFromAddress = cs ^. coreFromAddress , _systemReplyToAddress = cs ^. coreReplyToAddress , _systemSendmailPath = cs ^. coreSendmailPath+ , _postLoginRedirect = cs ^. coreLoginRedirect+ , _createUserCallback = Nothing } passwordConfig = PasswordConfig { _resetLink = baseUri <> authShowFn ResetPassword [] <> "/#"@@ -91,11 +95,12 @@ , _passwordAcceptable = const Nothing } - passwordState <- openLocalStateFrom (combine basePath "password") initialPasswordState- (authCleanup, routeAuthenticate, authenticateState) <- initAuthentication (Just basePath) authenticateConfig- ((initPassword' passwordConfig passwordState) : if True then [ initOpenId ] else [])+ passwordState <- openLocalStateFrom (combine (combine basePath "authenticate") "password") initialPasswordState+ passwordConfigTV <- atomically $ newTVar passwordConfig+ (authCleanup, routeAuthenticate, authenticateState, authenticateConfigTV) <- initAuthentication (Just basePath) authenticateConfig+ ((initPassword' passwordConfigTV passwordState) : if True then [ initOpenId ] else []) addHandler plugins (pluginName authenticatePlugin) (authenticateHandler routeAuthenticate authShowFn)- addPluginState plugins (pluginName authenticatePlugin) (AcidStateAuthenticate authenticateState passwordState)+ addPluginState plugins (pluginName authenticatePlugin) (AuthenticatePluginState authenticateState passwordState authenticateConfigTV passwordConfigTV) addCleanup plugins Always authCleanup return Nothing {-@@ -133,8 +138,8 @@ getUserId :: (Happstack m) => ClckT url m (Maybe UserId) getUserId = do p <- plugins <$> get- ~(Just (AcidStateAuthenticate authenticateState _)) <- getPluginState p (pluginName authenticatePlugin)- mToken <- getToken authenticateState+ ~(Just aps) <- getPluginState p (pluginName authenticatePlugin)+ mToken <- getToken (acidStateAuthenticate aps) case mToken of Nothing -> return Nothing (Just (token, _)) -> return $ Just (token ^. tokenUser ^. userId)
Clckwrks/Monad.hs view
@@ -327,9 +327,9 @@ ------------------------------------------------------------------------------ data ClckPluginsSt = ClckPluginsSt- { cpsPreProcessors :: forall m. (Functor m, MonadIO m, Happstack m) => [TL.Text -> ClckT ClckURL m TL.Text]- , cpsNavBarLinks :: [ClckT ClckURL IO (String, [NamedLink])]- , cpsAcid :: Acid -- ^ this value is also in ClckState, but it is sometimes needed by plugins during initPlugin+ { cpsPreProcessors :: forall m. (Functor m, MonadIO m, Happstack m) => [TL.Text -> ClckT ClckURL m TL.Text]+ , cpsNavBarLinks :: [ClckT ClckURL IO (String, [NamedLink])]+ , cpsAcid :: Acid -- ^ this value is also in ClckState, but it is sometimes needed by plugins during initPlugin } initialClckPluginsSt :: Acid -> ClckPluginsSt
Clckwrks/ProfileData/EditNewProfileData.hs view
@@ -6,7 +6,7 @@ import Clckwrks.Monad (getRedirectCookie) import Clckwrks.Admin.Template (emptyTemplate) import Clckwrks.Authenticate.Plugin (authenticatePlugin)-import Clckwrks.Authenticate.Monad (AcidStateAuthenticate(..))+import Clckwrks.Authenticate.Monad (AuthenticatePluginState(..)) import Clckwrks.ProfileData.Acid (GetProfileData(..), SetProfileData(..)) import Clckwrks.ProfileData.EditProfileData(profileDataFormlet) import Control.Monad.State (get)@@ -35,8 +35,8 @@ (Just uid) -> do -- pd <- query (GetProfileData uid) p <- plugins <$> get- ~(Just (AcidStateAuthenticate authenticateState _)) <- getPluginState p (pluginName authenticatePlugin)- ~(Just user) <- liftIO $ Acid.query authenticateState (GetUserByUserId uid)+ ~(Just aps) <- getPluginState p (pluginName authenticatePlugin)+ ~(Just user) <- liftIO $ Acid.query (acidStateAuthenticate aps) (GetUserByUserId uid) pd <- query (GetProfileData uid) action <- showURL here emptyTemplate "Edit Profile Data" () $
Clckwrks/ProfileData/EditProfileData.hs view
@@ -5,7 +5,7 @@ import Clckwrks.Monad (plugins) import Clckwrks.Admin.Template (template) import Clckwrks.Authenticate.Plugin (authenticatePlugin)-import Clckwrks.Authenticate.Monad (AcidStateAuthenticate(..))+import Clckwrks.Authenticate.Monad (AuthenticatePluginState(..)) import Clckwrks.ProfileData.Acid (GetProfileData(..), SetProfileData(..)) import Control.Monad.State (get) import Control.Monad.Trans (liftIO)@@ -34,8 +34,8 @@ (Just uid) -> do -- pd <- query (GetProfileData uid) p <- plugins <$> get- ~(Just (AcidStateAuthenticate authenticateState _)) <- getPluginState p (pluginName authenticatePlugin)- ~(Just user) <- liftIO $ Acid.query authenticateState (GetUserByUserId uid)+ ~(Just aps) <- getPluginState p (pluginName authenticatePlugin)+ ~(Just user) <- liftIO $ Acid.query (acidStateAuthenticate aps) (GetUserByUserId uid) pd <- query (GetProfileData uid) action <- showURL here template "Edit Profile Data" () $ [hsx|@@ -71,8 +71,8 @@ do let user = u { _email = if Text.null eml then Nothing else (Just (Email eml)) } p <- plugins <$> get- ~(Just (AcidStateAuthenticate authenticateState _)) <- getPluginState p (pluginName authenticatePlugin)- liftIO $ Acid.update authenticateState (UpdateUser user)+ ~(Just aps) <- getPluginState p (pluginName authenticatePlugin)+ liftIO $ Acid.update (acidStateAuthenticate aps) (UpdateUser user) pd <- query (GetProfileData _userId) update (SetProfileData (pd { displayName = if Text.null dn then Nothing else Just (DisplayName dn) })) pure $ Right ()
Clckwrks/ProfileData/EditProfileDataFor.hs view
@@ -2,17 +2,17 @@ module Clckwrks.ProfileData.EditProfileDataFor where import Clckwrks-import Clckwrks.Admin.Template (template)+import Clckwrks.Admin.Template (template) import Clckwrks.ProfileData.Acid (GetProfileData(..), SetProfileData(..))-import Clckwrks.Authenticate.Monad (AcidStateAuthenticate(..))-import Clckwrks.Authenticate.URL (AuthURL(ResetPassword))-import Control.Monad.State (get)-import Data.Maybe (fromMaybe)-import Data.Set as Set-import Data.Text.Lazy (Text)-import qualified Data.Text.Lazy as LT-import qualified Data.Text as Text-import Data.UserId (UserId)+import Clckwrks.Authenticate.Monad (AuthenticatePluginState(..))+import Clckwrks.Authenticate.URL (AuthURL(ResetPassword))+import Control.Monad.State (get)+import Data.Maybe (fromMaybe)+import Data.Set as Set+import Data.Text.Lazy (Text)+import qualified Data.Text.Lazy as LT+import qualified Data.Text as Text+import Data.UserId (UserId) import Language.Haskell.HSX.QQ (hsx) import Happstack.Authenticate.Core (Email(..), GetUserByUserId(..), User(..), UserId(..), Username(..))@@ -61,7 +61,7 @@ generateResetLink :: UserId -> Maybe Text.Text -> Clck ProfileDataURL Response generateResetLink uid _ = do p <- plugins <$> get- ~(Just (AcidStateAuthenticate authenticateState passwordState)) <- getPluginState p "authenticate"+ ~(Just aps) <- getPluginState p "authenticate" ~(Just authShowURL) <- getPluginRouteFn p "authenticate" cc <- getConfig p let basePath = maybe "_state" (\top -> top </> "_state") (clckTopDir cc)@@ -70,7 +70,7 @@ (Just b) -> b resetLink = authShowURL ResetPassword [] <> "/#"- eResetTokenLink <- liftIO $ resetTokenForUserId resetLink authenticateState passwordState uid+ eResetTokenLink <- liftIO $ resetTokenForUserId resetLink (acidStateAuthenticate aps) (acidStatePassword aps) uid case eResetTokenLink of (Left e) -> template "Reset Password Link" () $ [hsx|
clckwrks.cabal view
@@ -1,5 +1,5 @@ Name: clckwrks-Version: 0.27.2+Version: 0.28.0 Synopsis: A secure, reliable content management system (CMS) and blogging platform Description: clckwrks (pronounced, clockworks) aims to compete directly with popular PHP-based blogging and CMS@@ -107,7 +107,7 @@ containers >= 0.4 && < 0.7, directory >= 1.1 && < 1.4, filepath >= 1.2 && < 1.5,- happstack-authenticate >= 2.5.1 && < 2.6,+ happstack-authenticate >= 2.6 && < 2.7, happstack-hsp == 7.3.*, happstack-jmacro >= 7.0 && < 7.1, happstack-server >= 7.0 && < 7.8,