@@ -46,6 +46,8 @@ type UserSearchDescription = Description "Searches for users with the given stri
47type UpdateUserDescription = Description "Updates the current user.\n\nThrow 401 if you try to change email or something like that."
47type UpdateUserDescription = Description "Updates the current user.\n\nThrow 401 if you try to change email or something like that."
49+type DeactivateAllDescription = Description "Deactivates all tokens for the logged in user including the one used to authenticate this request."
49-- MARK: Implementation
51-- MARK: Implementation
51type Authentication = AuthProtect "basicAuth"
53type Authentication = AuthProtect "basicAuth"
@@ -55,6 +57,8 @@ type API =
55 "authentication" :> AuthenticationHandler :<|>
57 "authentication" :> AuthenticationHandler :<|>
56 Authentication :> ComplexQuery :> (
58 Authentication :> ComplexQuery :> (
57 "authentication" :> "me" :> Post '[JSON] UserId :<|>
59 "authentication" :> "me" :> Post '[JSON] UserId :<|>
60+ "deactivateAll" :> DeactivateAllDescription
61+ :> DeleteNoContent '[JSON, PlainText, FormUrlEncoded] NoContent :<|>
58 "users" :> ReqBody '[JSON] [UserId] :> Post '[JSON] [User Faculty] :<|>
62 "users" :> ReqBody '[JSON] [UserId] :> Post '[JSON] [User Faculty] :<|>
59 "users" :> "all" :> Post '[JSON] [User Faculty] :<|>
63 "users" :> "all" :> Post '[JSON] [User Faculty] :<|>
60 "users" :> "search" :> UserSearchDescription :> ReqBody '[JSON, PlainText] Text :> Post '[JSON] [User Faculty] :<|>
64 "users" :> "search" :> UserSearchDescription :> ReqBody '[JSON, PlainText] Text :> Post '[JSON] [User Faculty] :<|>
@@ -74,6 +78,7 @@ mkServerAPI l =
75 authenticationAPI :<|> (\uId ->
79 authenticationAPI :<|> (\uId ->
76 return uId :<|>
80 return uId :<|>
81+ deactivateApi uId :<|>
77 maybeNotFound . runQnotFound . getUsers :<|>
82 maybeNotFound . runQnotFound . getUsers :<|>
78 runQerror getAllUsers :<|>
83 runQerror getAllUsers :<|>
79 runQerror . searchUsers :<|>
84 runQerror . searchUsers :<|>
@@ -96,4 +101,7 @@ updateUserApi uId UserUpdate{..} = do
97 if isJust res
102 if isJust res
98 then return NoContent
103 then return NoContent
99− else throwError err401
104+ else throwError err401
106+deactivateApi :: UserId -> App NoContent
107+deactivateApi uId = runQerror (killAllTokens uId) >> return NoContent