[backend/api] Make auth endpoints RESTful

This commit is contained in:
Laura Hausmann 2024-04-22 20:01:48 +02:00
parent 86c0ab02b5
commit e4814804c0
No known key found for this signature in database
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] [HideRequestDuration]
[EnableRateLimiting("strict")] [EnableRateLimiting("strict")]
[Consumes(MediaTypeNames.Application.Json)] [Consumes(MediaTypeNames.Application.Json)]
@ -82,7 +82,7 @@ public class AuthController(DatabaseContext db, UserService userSvc, UserRendere
}); });
} }
[HttpPut] [HttpPost("register")]
[EnableRateLimiting("strict")] [EnableRateLimiting("strict")]
[Consumes(MediaTypeNames.Application.Json)] [Consumes(MediaTypeNames.Application.Json)]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AuthResponse))] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AuthResponse))]
@ -97,7 +97,7 @@ public class AuthController(DatabaseContext db, UserService userSvc, UserRendere
return await Login(request); return await Login(request);
} }
[HttpPatch] [HttpPost("change-password")]
[Authenticate] [Authenticate]
[Authorize] [Authorize]
[EnableRateLimiting("strict")] [EnableRateLimiting("strict")]

View file

@ -9,11 +9,11 @@ internal class AuthControllerModel(ApiClient api)
api.Call<AuthResponse>(HttpMethod.Get, "/auth"); api.Call<AuthResponse>(HttpMethod.Get, "/auth");
public Task<AuthResponse> Login(AuthRequest request) => 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) => 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) => public Task<AuthResponse> ChangePassword(ChangePasswordRequest request) =>
api.Call<AuthResponse>(HttpMethod.Patch, "/auth", data: request); api.Call<AuthResponse>(HttpMethod.Post, "/auth/change-password", data: request);
} }