do not ask for user id, it comes from auth anyway
This commit is contained in:
parent
f1518f4100
commit
3a5cb7c5ac
2 changed files with 5 additions and 13 deletions
|
@ -33,8 +33,7 @@ type MateAPI =
|
||||||
:> ReqBody '[JSON] Int :> Delete '[JSON] ()
|
:> ReqBody '[JSON] Int :> Delete '[JSON] ()
|
||||||
|
|
||||||
:<|> "user" :> ReqBody '[JSON] UserSubmit :> Post '[JSON] Int
|
:<|> "user" :> ReqBody '[JSON] UserSubmit :> Post '[JSON] Int
|
||||||
:<|> "user" :> AuthProtect "header-auth"
|
:<|> "user" :> AuthProtect "header-auth" :> Get '[JSON] UserDetails
|
||||||
:> Capture "uid'" Int :> Get '[JSON] UserDetails
|
|
||||||
:<|> "user" :> AuthProtect "header-auth"
|
:<|> "user" :> AuthProtect "header-auth"
|
||||||
:> ReqBody '[JSON] UserDetailsSubmit :> Patch '[JSON] ()
|
:> ReqBody '[JSON] UserDetailsSubmit :> Patch '[JSON] ()
|
||||||
:<|> "user" :> "list" :> QueryParam "refine" UserRefine :> Get '[JSON] [UserSummary]
|
:<|> "user" :> "list" :> QueryParam "refine" UserRefine :> Get '[JSON] [UserSummary]
|
||||||
|
|
|
@ -32,21 +32,14 @@ userNew (UserSubmit ident email passhash) = do
|
||||||
|
|
||||||
userGet
|
userGet
|
||||||
:: Maybe (Int, AuthMethod)
|
:: Maybe (Int, AuthMethod)
|
||||||
-> Int
|
|
||||||
-> MateHandler UserDetails
|
-> MateHandler UserDetails
|
||||||
userGet Nothing _ =
|
userGet Nothing =
|
||||||
throwError $ err401
|
throwError $ err401
|
||||||
{ errBody = "No Authentication present."
|
{ errBody = "No Authentication present."
|
||||||
}
|
}
|
||||||
userGet (Just (aid, method)) uid =
|
userGet (Just (uid, _)) = do
|
||||||
if aid == uid && any (== method) [PrimaryPass, ChallengeResponse]
|
conn <- rsConnection <$> ask
|
||||||
then do
|
userDetailsSelect uid conn
|
||||||
conn <- rsConnection <$> ask
|
|
||||||
userDetailsSelect uid conn
|
|
||||||
else
|
|
||||||
throwError $ err401
|
|
||||||
{ errBody = "Wrong Authentication present."
|
|
||||||
}
|
|
||||||
|
|
||||||
userUpdate
|
userUpdate
|
||||||
:: Maybe (Int, AuthMethod)
|
:: Maybe (Int, AuthMethod)
|
||||||
|
|
Loading…
Reference in a new issue