add flag for mock auth and clean a little
This commit is contained in:
parent
e75dc37fe3
commit
d8b3c7feab
4 changed files with 22 additions and 2 deletions
|
@ -15,6 +15,11 @@ maintainer: nek0@nek0.eu
|
||||||
category: Web
|
category: Web
|
||||||
extra-source-files: CHANGELOG.md
|
extra-source-files: CHANGELOG.md
|
||||||
|
|
||||||
|
flag develop
|
||||||
|
description: compile mateamt in developer mode. Authentication disabled,
|
||||||
|
default: False
|
||||||
|
manual: True
|
||||||
|
|
||||||
executable mateamt
|
executable mateamt
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
other-modules: API
|
other-modules: API
|
||||||
|
@ -50,3 +55,5 @@ executable mateamt
|
||||||
, mtl
|
, mtl
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
if flag(develop)
|
||||||
|
cpp-options: -DDEVELOP
|
||||||
|
|
|
@ -13,6 +13,7 @@ let
|
||||||
pname = "mateamt";
|
pname = "mateamt";
|
||||||
version = "0.0.0.0";
|
version = "0.0.0.0";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
configureFlags = [ "-fdevelop" ];
|
||||||
isLibrary = false;
|
isLibrary = false;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
executableHaskellDepends = [
|
executableHaskellDepends = [
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
{-# LANGUAGE DeriveGeneric #-}
|
{-# LANGUAGE DeriveGeneric #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
module Model.Auth where
|
module Model.Auth where
|
||||||
|
@ -213,9 +214,21 @@ processAuthRequest (AuthRequest aticket hash) = do
|
||||||
liftIO $ threadDelay $ 1 * 10 ^ 6
|
liftIO $ threadDelay $ 1 * 10 ^ 6
|
||||||
if now > ticketExpiry ticket
|
if now > ticketExpiry ticket
|
||||||
then
|
then
|
||||||
|
#if defined(DEVELOP)
|
||||||
|
do
|
||||||
|
mockticket <- Ticket <$> pure aticket <*> pure 1 <*> liftIO getCurrentTime
|
||||||
|
generateToken mockticket hash
|
||||||
|
#else
|
||||||
return Denied
|
return Denied
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
generateToken ticket hash
|
generateToken ticket hash
|
||||||
_ -> do
|
_ -> do
|
||||||
liftIO $ threadDelay $ 1 * 10 ^ 6
|
liftIO $ threadDelay $ 1 * 10 ^ 6
|
||||||
|
#if defined(DEVELOP)
|
||||||
|
do
|
||||||
|
mockticket <- Ticket <$> pure aticket <*> pure 1 <*> liftIO getCurrentTime
|
||||||
|
generateToken mockticket hash
|
||||||
|
#else
|
||||||
return Denied
|
return Denied
|
||||||
|
#endif
|
||||||
|
|
|
@ -74,9 +74,8 @@ userTable = table "user" (
|
||||||
userSelect
|
userSelect
|
||||||
:: PGS.Connection
|
:: PGS.Connection
|
||||||
-> Maybe Refine
|
-> Maybe Refine
|
||||||
-> Bool
|
|
||||||
-> MateHandler [User]
|
-> MateHandler [User]
|
||||||
userSelect conn ref sw = do
|
userSelect conn ref = do
|
||||||
today <- utctDay <$> (liftIO $ getCurrentTime)
|
today <- utctDay <$> (liftIO $ getCurrentTime)
|
||||||
users <- liftIO $ runSelect conn (case ref of
|
users <- liftIO $ runSelect conn (case ref of
|
||||||
Nothing -> keepWhen (\(_, _, _, ts, _, _, _, _, _) ->
|
Nothing -> keepWhen (\(_, _, _, ts, _, _, _, _, _) ->
|
||||||
|
|
Loading…
Reference in a new issue