generated from coulomb/repo-seed
fix(WP-0016): Layer 3 compilation fixes — Sessions auth, Widgets import consolidation, Scientific type
- Sessions: replace raw authenticate/unsetSession with IHP login/logout/verifyPassword - Widgets/New, Widgets/Show: consolidate imports to Web.View.Prelude - Widgets/Show: unwrap Id newtype for childrenOf comparison, Double → Scientific in renderSignalValue Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,8 @@ import Web.Types
|
||||
import Web.View.Sessions.New
|
||||
import Generated.Types
|
||||
import IHP.LoginSupport.Helper.Controller
|
||||
import IHP.AuthSupport.Controller.Sessions (SessionsControllerConfig)
|
||||
import IHP.AuthSupport.Controller.Sessions (SessionsControllerConfig (..))
|
||||
import IHP.AuthSupport.Authentication (verifyPassword)
|
||||
import IHP.Prelude
|
||||
import IHP.ControllerPrelude
|
||||
|
||||
@@ -14,17 +15,20 @@ instance Controller SessionsController where
|
||||
render NewView { user }
|
||||
|
||||
action CreateSessionAction = do
|
||||
(user, token) <- authenticate @User
|
||||
case user of
|
||||
Just user -> do
|
||||
setSession "userId" (show user.id)
|
||||
maybeUser <- query @User
|
||||
|> filterWhere (#email, param "email")
|
||||
|> fetchOneOrNothing
|
||||
case maybeUser of
|
||||
Just user | verifyPassword user (param "password") -> do
|
||||
login user
|
||||
redirectTo HubsAction
|
||||
Nothing -> do
|
||||
_ -> do
|
||||
setErrorMessage "Invalid email or password"
|
||||
redirectTo NewSessionAction
|
||||
|
||||
action DeleteSessionAction = do
|
||||
unsetSession "userId"
|
||||
redirectTo NewSessionAction
|
||||
currentUserOrNothing @User >>= \case
|
||||
Just user -> logout user >> redirectTo NewSessionAction
|
||||
Nothing -> redirectTo NewSessionAction
|
||||
|
||||
instance SessionsControllerConfig User
|
||||
|
||||
Reference in New Issue
Block a user