@@ -46,6 +46,8 @@ type UserSearchDescription = Description "Searches for users with the given stri
4646
4747type UpdateUserDescription = Description "Updates the current user.\n\nThrow 401 if you try to change email or something like that."
4848
49+type DeactivateAllDescription = Description "Deactivates all tokens for the logged in user including the one used to authenticate this request."
50+
4951-- MARK: Implementation
5052
5153type Authentication = AuthProtect "basicAuth"
@@ -55,6 +57,8 @@ type API =
5557 "authentication" :> AuthenticationHandler :<|>
5658 Authentication :> ComplexQuery :> (
5759 "authentication" :> "me" :> Post '[JSON] UserId :<|>
60+ "deactivateAll" :> DeactivateAllDescription
61+ :> DeleteNoContent '[JSON, PlainText, FormUrlEncoded] NoContent :<|>
5862 "users" :> ReqBody '[JSON] [UserId] :> Post '[JSON] [User Faculty] :<|>
5963 "users" :> "all" :> Post '[JSON] [User Faculty] :<|>
6064 "users" :> "search" :> UserSearchDescription :> ReqBody '[JSON, PlainText] Text :> Post '[JSON] [User Faculty] :<|>
@@ -74,6 +78,7 @@ mkServerAPI l =
7478 l :<|>
7579 authenticationAPI :<|> (\uId ->
7680 return uId :<|>
81+ deactivateApi uId :<|>
7782 maybeNotFound . runQnotFound . getUsers :<|>
7883 runQerror getAllUsers :<|>
7984 runQerror . searchUsers :<|>
@@ -96,4 +101,7 @@ updateUserApi uId UserUpdate{..} = do
96101 }
97102 if isJust res
98103 then return NoContent
99− else throwError err401
104+ else throwError err401
105+
106+deactivateApi :: UserId -> App NoContent
107+deactivateApi uId = runQerror (killAllTokens uId) >> return NoContent