mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
Add delete user endpoint
This commit is contained in:
parent
56930972fe
commit
b949b30f24
1 changed files with 15 additions and 0 deletions
|
@ -9,6 +9,7 @@ pub fn add_routes(app: &mut tide::Server<Arc<AppState>>) {
|
|||
app.at("/users").get(get_users);
|
||||
app.at("/users").post(create_user);
|
||||
app.at("/users/:id").put(update_user);
|
||||
app.at("/users/:id").delete(delete_user);
|
||||
app.at("/users/:github_login").get(get_user);
|
||||
app.at("/users/:github_login/access_tokens")
|
||||
.post(create_access_token);
|
||||
|
@ -88,6 +89,20 @@ async fn update_user(mut request: Request) -> tide::Result {
|
|||
Ok(tide::Response::builder(StatusCode::Ok).build())
|
||||
}
|
||||
|
||||
async fn delete_user(request: Request) -> tide::Result {
|
||||
request.require_token().await?;
|
||||
let user_id = UserId(
|
||||
request
|
||||
.param("id")?
|
||||
.parse::<i32>()
|
||||
.map_err(|error| surf::Error::from_str(StatusCode::BadRequest, error.to_string()))?,
|
||||
);
|
||||
|
||||
request.db().delete_user(user_id).await?;
|
||||
|
||||
Ok(tide::Response::builder(StatusCode::Ok).build())
|
||||
}
|
||||
|
||||
async fn create_access_token(request: Request) -> tide::Result {
|
||||
request.require_token().await?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue