feat: Implement account deletion feature with UI and API integration
Some checks failed
Deploy tt-tagebuch / deploy (push) Has been cancelled
Some checks failed
Deploy tt-tagebuch / deploy (push) Has been cancelled
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package de.tsschulz.tt_tagebuch.shared.api
|
||||
|
||||
import de.tsschulz.tt_tagebuch.shared.api.http.AuthedHttpClient
|
||||
import de.tsschulz.tt_tagebuch.shared.api.models.DeleteAccountRequest
|
||||
import de.tsschulz.tt_tagebuch.shared.api.models.LoginRequest
|
||||
import de.tsschulz.tt_tagebuch.shared.api.models.LoginResponse
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.request.delete
|
||||
import io.ktor.client.request.post
|
||||
import io.ktor.client.request.setBody
|
||||
|
||||
@@ -19,4 +21,10 @@ class AuthApi(
|
||||
suspend fun logout() {
|
||||
client.http.post("/api/auth/logout")
|
||||
}
|
||||
|
||||
suspend fun deleteAccount(password: String) {
|
||||
client.http.delete("/api/auth/account") {
|
||||
setBody(DeleteAccountRequest(password = password))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,3 +8,8 @@ data class LoginRequest(
|
||||
val password: String,
|
||||
val rememberMe: Boolean = false,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class DeleteAccountRequest(
|
||||
val password: String,
|
||||
)
|
||||
|
||||
@@ -54,6 +54,11 @@ class AuthManager(
|
||||
clearLocal()
|
||||
}
|
||||
|
||||
suspend fun deleteAccount(password: String) {
|
||||
authApi.deleteAccount(password)
|
||||
clearLocal()
|
||||
}
|
||||
|
||||
suspend fun clearLocal() {
|
||||
tokenProvider.token = null
|
||||
tokenProvider.username = null
|
||||
|
||||
Reference in New Issue
Block a user