Keep track of userLastAuthentication
This commit is contained in:
parent
57cb80ecf8
commit
ad02db27db
@ -253,8 +253,10 @@ Theme: Oberflächen Design
|
|||||||
Favoriten: Anzahl gespeicherter Favoriten
|
Favoriten: Anzahl gespeicherter Favoriten
|
||||||
Plugin: Plugin
|
Plugin: Plugin
|
||||||
Ident: Identifikation
|
Ident: Identifikation
|
||||||
|
LastLogin: Letzter Login
|
||||||
Settings: Individuelle Benutzereinstellungen
|
Settings: Individuelle Benutzereinstellungen
|
||||||
SettingsUpdate: Einstellungen wurden gespeichert.
|
SettingsUpdate: Einstellungen wurden gespeichert.
|
||||||
|
Never: Nie
|
||||||
|
|
||||||
MultiFileUploadInfo: (Mehrere Dateien mit Shift oder Strg auswählen)
|
MultiFileUploadInfo: (Mehrere Dateien mit Shift oder Strg auswählen)
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
User json
|
User json
|
||||||
ident (CI Text)
|
ident (CI Text)
|
||||||
authentication AuthenticationMode
|
authentication AuthenticationMode
|
||||||
|
lastAuthentication UTCTime Maybe
|
||||||
matrikelnummer Text Maybe
|
matrikelnummer Text Maybe
|
||||||
email (CI Text)
|
email (CI Text)
|
||||||
displayName Text
|
displayName Text
|
||||||
|
|||||||
@ -80,8 +80,6 @@ import Data.Bits (Bits(zeroBits))
|
|||||||
|
|
||||||
import Network.Wai.Parse (lbsBackEnd)
|
import Network.Wai.Parse (lbsBackEnd)
|
||||||
|
|
||||||
import qualified Data.UUID.V4 as UUID
|
|
||||||
|
|
||||||
|
|
||||||
instance DisplayAble b => DisplayAble (E.CryptoID a b) where
|
instance DisplayAble b => DisplayAble (E.CryptoID a b) where
|
||||||
display = display . ciphertext
|
display = display . ciphertext
|
||||||
@ -1916,6 +1914,8 @@ instance YesodAuth UniWorX where
|
|||||||
$(widgetFile "login")
|
$(widgetFile "login")
|
||||||
|
|
||||||
authenticate Creds{..} = runDB $ do
|
authenticate Creds{..} = runDB $ do
|
||||||
|
now <- liftIO getCurrentTime
|
||||||
|
|
||||||
let
|
let
|
||||||
userIdent = CI.mk credsIdent
|
userIdent = CI.mk credsIdent
|
||||||
uAuth = UniqueAuthentication userIdent
|
uAuth = UniqueAuthentication userIdent
|
||||||
@ -1943,7 +1943,12 @@ instance YesodAuth UniWorX where
|
|||||||
return $ ServerError "LDAP lookup failed"
|
return $ ServerError "LDAP lookup failed"
|
||||||
]
|
]
|
||||||
|
|
||||||
acceptExisting = maybe (UserError $ IdentifierNotFound credsIdent) (Authenticated . entityKey) <$> getBy uAuth
|
acceptExisting = do
|
||||||
|
res <- maybe (UserError $ IdentifierNotFound credsIdent) (Authenticated . entityKey) <$> getBy uAuth
|
||||||
|
case res of
|
||||||
|
Authenticated uid
|
||||||
|
| not isDummy -> res <$ update uid [ UserLastAuthentication =. Just now ]
|
||||||
|
_other -> return res
|
||||||
|
|
||||||
$logDebugS "auth" $ tshow Creds{..}
|
$logDebugS "auth" $ tshow Creds{..}
|
||||||
UniWorX{ appSettings = AppSettings{ appUserDefaults = UserDefaultConf{..}, ..}, .. } <- getYesod
|
UniWorX{ appSettings = AppSettings{ appUserDefaults = UserDefaultConf{..}, ..}, .. } <- getYesod
|
||||||
@ -1962,6 +1967,7 @@ instance YesodAuth UniWorX where
|
|||||||
userAuthentication
|
userAuthentication
|
||||||
| isPWHash = error "PWHash should only work for users that are already known"
|
| isPWHash = error "PWHash should only work for users that are already known"
|
||||||
| otherwise = AuthLDAP
|
| otherwise = AuthLDAP
|
||||||
|
userLastAuthentication = now <$ guard (not isDummy)
|
||||||
|
|
||||||
userEmail <- if
|
userEmail <- if
|
||||||
| Just [bs] <- userEmail'
|
| Just [bs] <- userEmail'
|
||||||
@ -2002,15 +2008,15 @@ instance YesodAuth UniWorX where
|
|||||||
, userMailLanguages = def
|
, userMailLanguages = def
|
||||||
, ..
|
, ..
|
||||||
}
|
}
|
||||||
userUpdate = [ UserMatrikelnummer =. userMatrikelnummer
|
userUpdate = [ UserMatrikelnummer =. userMatrikelnummer
|
||||||
, UserDisplayName =. userDisplayName
|
, UserDisplayName =. userDisplayName
|
||||||
, UserSurname =. userSurname
|
, UserSurname =. userSurname
|
||||||
, UserEmail =. userEmail
|
, UserEmail =. userEmail
|
||||||
]
|
] ++
|
||||||
|
[ UserLastAuthentication =. Just now | not isDummy ]
|
||||||
|
|
||||||
userId <- lift $ entityKey <$> upsertBy uAuth newUser userUpdate
|
userId <- lift $ entityKey <$> upsertBy uAuth newUser userUpdate
|
||||||
studyTermCandidateIncidence <- liftIO UUID.nextRandom
|
studyTermCandidateIncidence <- liftIO getRandom
|
||||||
now <- liftIO getCurrentTime
|
|
||||||
|
|
||||||
let
|
let
|
||||||
userStudyFeatures = fmap concat . forM userStudyFeatures' $ parseStudyFeatures userId now
|
userStudyFeatures = fmap concat . forM userStudyFeatures' $ parseStudyFeatures userId now
|
||||||
|
|||||||
@ -302,8 +302,8 @@ registerForm registered msecret extra = do
|
|||||||
(msecretRes', msecretView) <- case msecret of
|
(msecretRes', msecretView) <- case msecret of
|
||||||
(Just _) | not registered -> bimap Just Just <$> mreq textField (fslpI MsgCourseSecret "Code") Nothing
|
(Just _) | not registered -> bimap Just Just <$> mreq textField (fslpI MsgCourseSecret "Code") Nothing
|
||||||
_ -> return (Nothing,Nothing)
|
_ -> return (Nothing,Nothing)
|
||||||
(sfRes' , sfView) <- if not registered then return (Nothing,Nothing) else
|
(_msfRes, msfView) <- if not registered then return (Nothing, Nothing) else
|
||||||
mopt (studyFeaturesPrimaryFieldFor (error "TODO SJ REMOVE")) (fslI MsgCourseStudyFeature) Nothing
|
bimap Just Just <$> mopt (studyFeaturesPrimaryFieldFor (error "TODO SJ REMOVE")) (fslI MsgCourseStudyFeature) Nothing
|
||||||
(btnRes, btnView) <- mreq (buttonField $ bool BtnRegister BtnDeregister registered) "buttonField ignores settings anyway" Nothing
|
(btnRes, btnView) <- mreq (buttonField $ bool BtnRegister BtnDeregister registered) "buttonField ignores settings anyway" Nothing
|
||||||
|
|
||||||
let widget = $(widgetFile "widgets/register-form/register-form")
|
let widget = $(widgetFile "widgets/register-form/register-form")
|
||||||
|
|||||||
@ -248,6 +248,8 @@ getProfileDataR = do
|
|||||||
let ownTutorialTable = [whamlet|Übungsgruppen werden momentan leider noch nicht unterstützt.|]
|
let ownTutorialTable = [whamlet|Übungsgruppen werden momentan leider noch nicht unterstützt.|]
|
||||||
let tutorialTable = [whamlet|Übungsgruppen werden momentan leider noch nicht unterstützt.|]
|
let tutorialTable = [whamlet|Übungsgruppen werden momentan leider noch nicht unterstützt.|]
|
||||||
|
|
||||||
|
lastLogin <- traverse (formatTime SelFormatDateTime) userLastAuthentication
|
||||||
|
|
||||||
-- Delete Button
|
-- Delete Button
|
||||||
(btnWdgt, btnEnctype) <- generateFormPost (buttonForm :: Form ButtonDelete)
|
(btnWdgt, btnEnctype) <- generateFormPost (buttonForm :: Form ButtonDelete)
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
|
|||||||
@ -61,6 +61,9 @@ import Database.Esqueleto.Instances as Import ()
|
|||||||
import Database.Persist.Sql.Instances as Import ()
|
import Database.Persist.Sql.Instances as Import ()
|
||||||
import Database.Persist.Sql as Import (SqlReadT,SqlWriteT)
|
import Database.Persist.Sql as Import (SqlReadT,SqlWriteT)
|
||||||
|
|
||||||
|
import System.Random as Import (Random)
|
||||||
|
import Control.Monad.Random.Class as Import (MonadRandom(..))
|
||||||
|
|
||||||
|
|
||||||
import Control.Monad.Trans.RWS (RWST)
|
import Control.Monad.Trans.RWS (RWST)
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,12 @@
|
|||||||
<dd .deflist__dd> #{display userEmail}
|
<dd .deflist__dd> #{display userEmail}
|
||||||
<dt .deflist__dt> _{MsgIdent}
|
<dt .deflist__dt> _{MsgIdent}
|
||||||
<dd .deflist__dd> #{display userIdent}
|
<dd .deflist__dd> #{display userIdent}
|
||||||
|
<dt .deflist__dt> _{MsgLastLogin}
|
||||||
|
<dd .deflist__dd>
|
||||||
|
$maybe llogin <- lastLogin
|
||||||
|
#{llogin}
|
||||||
|
$nothing
|
||||||
|
_{MsgNever}
|
||||||
$if not $ null admin_rights
|
$if not $ null admin_rights
|
||||||
<dt .deflist__dt> Administrator
|
<dt .deflist__dt> Administrator
|
||||||
<dd .deflist__dd>
|
<dd .deflist__dd>
|
||||||
|
|||||||
@ -4,5 +4,7 @@ $# Maybe display textField for passcode
|
|||||||
$maybe secretView <- msecretView
|
$maybe secretView <- msecretView
|
||||||
^{fvInput secretView}
|
^{fvInput secretView}
|
||||||
$# Ask for associated primary field uf study, unless registered
|
$# Ask for associated primary field uf study, unless registered
|
||||||
|
$maybe sfView <- msfView
|
||||||
|
^{fvInput sfView}
|
||||||
$# Always display register/deregister button
|
$# Always display register/deregister button
|
||||||
^{fvInput btnView}
|
^{fvInput btnView}
|
||||||
|
|||||||
Reference in New Issue
Block a user