This commit is contained in:
Gregor Kleen 2019-04-05 17:15:26 +02:00
parent a6b23a739f
commit e947921955
9 changed files with 26 additions and 8 deletions

View File

@ -30,5 +30,5 @@ dispatchNotificationCorrectionsAssigned nUser nSheet jRecipient = do
editNotifications <- mkEditNotifications jRecipient
addAlternatives $ do
addAlternatives $
providePreferredAlternative ($(ihamletFile "templates/mail/correctionsAssigned.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))

View File

@ -29,5 +29,5 @@ dispatchNotificationSheetActive nSheet jRecipient = userMailT jRecipient $ do
editNotifications <- mkEditNotifications jRecipient
addAlternatives $ do
addAlternatives $
providePreferredAlternative ($(ihamletFile "templates/mail/sheetActive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))

View File

@ -32,7 +32,7 @@ dispatchNotificationSheetSoonInactive nSheet jRecipient = userMailT jRecipient $
editNotifications <- mkEditNotifications jRecipient
addAlternatives $ do
addAlternatives $
providePreferredAlternative ($(ihamletFile "templates/mail/sheetSoonInactive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))
dispatchNotificationSheetInactive :: SheetId -> UserId -> Handler ()
@ -58,6 +58,6 @@ dispatchNotificationSheetInactive nSheet jRecipient = userMailT jRecipient $ do
editNotifications <- mkEditNotifications jRecipient
addAlternatives $ do
addAlternatives $
providePreferredAlternative ($(ihamletFile "templates/mail/sheetInactive.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))

View File

@ -23,6 +23,6 @@ dispatchNotificationUserRightsUpdate nUser _originalRights jRecipient = userMai
setSubjectI $ MsgMailSubjectUserRightsUpdate userDisplayName
-- MsgRenderer mr <- getMailMsgRenderer
editNotifications <- mkEditNotifications jRecipient
addAlternatives $ do
addAlternatives $
providePreferredAlternative ($(ihamletFile "templates/mail/userRightsUpdate.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))

View File

@ -136,8 +136,8 @@ bearerToken :: forall m.
-> Maybe UTCTime -- ^ @Nothing@ means token starts to be valid immediately
-> m (BearerToken (HandlerSite m))
bearerToken tokenAuthority tokenRoutes tokenAddAuth mTokenExpiresAt tokenStartsAt = do
tokenIdentifier <- liftIO $ getRandom
tokenIssuedAt <- liftIO $ getCurrentTime
tokenIdentifier <- liftIO getRandom
tokenIssuedAt <- liftIO getCurrentTime
tokenIssuedBy <- getsYesod $ view instanceID
defaultExpiration <- getsYesod $ view _appJWTExpiration

11
test.sh
View File

@ -1,3 +1,14 @@
#!/usr/bin/env bash
move-back() {
mv -v .stack-work .stack-work-test
[[ -d .stack-work-build ]] && mv -v .stack-work-build .stack-work
}
if [[ -d .stack-work-test ]]; then
[[ -d .stack-work ]] && mv -v .stack-work .stack-work-build
mv -v .stack-work-test .stack-work
trap move-back EXIT
fi
exec -- stack build --test --fast --flag uniworx:dev --flag uniworx:library-only ${@}

View File

@ -94,6 +94,7 @@ fillDb = do
{ userIdent = "G.Kleen@campus.lmu.de"
, userAuthentication = AuthLDAP
, userLastAuthentication = Just now
, userTokensIssuedAfter = Just now
, userMatrikelnummer = Nothing
, userEmail = "G.Kleen@campus.lmu.de"
, userDisplayName = "Gregor Kleen"
@ -111,6 +112,7 @@ fillDb = do
{ userIdent = "felix.hamann@campus.lmu.de"
, userAuthentication = AuthLDAP
, userLastAuthentication = Nothing
, userTokensIssuedAfter = Nothing
, userMatrikelnummer = Nothing
, userEmail = "felix.hamann@campus.lmu.de"
, userDisplayName = "Felix Hamann"
@ -128,6 +130,7 @@ fillDb = do
{ userIdent = "jost@tcs.ifi.lmu.de"
, userAuthentication = AuthLDAP
, userLastAuthentication = Nothing
, userTokensIssuedAfter = Nothing
, userMatrikelnummer = Nothing
, userEmail = "jost@tcs.ifi.lmu.de"
, userDisplayName = "Steffen Jost"
@ -145,6 +148,7 @@ fillDb = do
{ userIdent = "max@campus.lmu.de"
, userAuthentication = AuthLDAP
, userLastAuthentication = Just now
, userTokensIssuedAfter = Nothing
, userMatrikelnummer = Just "1299"
, userEmail = "max@campus.lmu.de"
, userDisplayName = "Max Musterstudent"
@ -162,6 +166,7 @@ fillDb = do
{ userIdent = "tester@campus.lmu.de"
, userAuthentication = AuthLDAP
, userLastAuthentication = Nothing
, userTokensIssuedAfter = Nothing
, userMatrikelnummer = Just "999"
, userEmail = "tester@campus.lmu.de"
, userDisplayName = "Tina Tester"

View File

@ -41,6 +41,7 @@ instance Arbitrary User where
]
userAuthentication <- arbitrary
userLastAuthentication <- arbitrary
userTokensIssuedAfter <- arbitrary
userMatrikelnummer <- fmap pack . assertM' (not . null) <$> listOf (elements ['0'..'9'])
userEmail <- CI.mk . decodeUtf8 . Email.toByteString <$> arbitrary

View File

@ -103,11 +103,12 @@ authenticateAs (Entity _ User{..}) = do
-- checking is switched off in wipeDB for those database backends which need it.
createUser :: (User -> User) -> YesodExample UniWorX (Entity User)
createUser adjUser = do
UserDefaultConf{..} <- appUserDefaults . appSettings <$> getTestYesod
UserDefaultConf{..} <- appUserDefaults . view appSettings <$> getTestYesod
let
userMatrikelnummer = Nothing
userAuthentication = AuthLDAP
userLastAuthentication = Nothing
userTokensIssuedAfter = Nothing
userIdent = "dummy@example.invalid"
userEmail = "dummy@example.invalid"
userDisplayName = "Dummy Example"