[backend/api] Make auth endpoints RESTful
All checks were successful
/ unit-tests (push) Successful in 25s
/ build-and-push (push) Successful in 1m42s

This commit is contained in:
Laura Hausmann 2024-04-22 20:01:48 +02:00
parent 86c0ab02b5
commit e4814804c0
Signed by: zotan
GPG key ID: D044E84C5BE01605
2 changed files with 6 additions and 6 deletions

View file

@ -38,7 +38,7 @@ public class AuthController(DatabaseContext db, UserService userSvc, UserRendere
});
}
[HttpPost]
[HttpPost("login")]
[HideRequestDuration]
[EnableRateLimiting("strict")]
[Consumes(MediaTypeNames.Application.Json)]
@ -82,7 +82,7 @@ public class AuthController(DatabaseContext db, UserService userSvc, UserRendere
});
}
[HttpPut]
[HttpPost("register")]
[EnableRateLimiting("strict")]
[Consumes(MediaTypeNames.Application.Json)]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AuthResponse))]
@ -97,7 +97,7 @@ public class AuthController(DatabaseContext db, UserService userSvc, UserRendere
return await Login(request);
}
[HttpPatch]
[HttpPost("change-password")]
[Authenticate]
[Authorize]
[EnableRateLimiting("strict")]

View file

@ -9,11 +9,11 @@ internal class AuthControllerModel(ApiClient api)
api.Call<AuthResponse>(HttpMethod.Get, "/auth");
public Task<AuthResponse> Login(AuthRequest request) =>
api.Call<AuthResponse>(HttpMethod.Post, "/auth", data: request);
api.Call<AuthResponse>(HttpMethod.Post, "/auth/login", data: request);
public Task<AuthResponse> Register(RegistrationRequest request) =>
api.Call<AuthResponse>(HttpMethod.Put, "/auth", data: request);
api.Call<AuthResponse>(HttpMethod.Post, "/auth/register", data: request);
public Task<AuthResponse> ChangePassword(ChangePasswordRequest request) =>
api.Call<AuthResponse>(HttpMethod.Patch, "/auth", data: request);
api.Call<AuthResponse>(HttpMethod.Post, "/auth/change-password", data: request);
}