- DELETE /api/auth/account/ API call in AuthApi + APILayer - authProvider field on User model for email vs social auth detection - DeleteAccountDialog with password (email) or "type DELETE" (social) confirmation - Red "Delete Account" card on ProfileScreen - Navigation wired in App.kt (clears data, returns to login) - 10 i18n strings in strings.xml - ViewModel unit tests for delete account state
219 lines
4.9 KiB
Kotlin
219 lines
4.9 KiB
Kotlin
package com.tt.honeyDue.models
|
|
|
|
import kotlinx.serialization.SerialName
|
|
import kotlinx.serialization.Serializable
|
|
|
|
/**
|
|
* User model matching Go API UserResponse/CurrentUserResponse
|
|
*/
|
|
@Serializable
|
|
data class User(
|
|
val id: Int,
|
|
val username: String,
|
|
val email: String,
|
|
@SerialName("first_name") val firstName: String = "",
|
|
@SerialName("last_name") val lastName: String = "",
|
|
@SerialName("is_active") val isActive: Boolean = true,
|
|
@SerialName("date_joined") val dateJoined: String,
|
|
@SerialName("last_login") val lastLogin: String? = null,
|
|
@SerialName("auth_provider") val authProvider: String? = null,
|
|
// Profile is included in CurrentUserResponse (/auth/me)
|
|
val profile: UserProfile? = null,
|
|
// Verified is returned directly in LoginResponse, and also in profile for CurrentUserResponse
|
|
@SerialName("verified") private val _verified: Boolean = false
|
|
) {
|
|
// Computed property for display name
|
|
val displayName: String
|
|
get() = when {
|
|
firstName.isNotBlank() && lastName.isNotBlank() -> "$firstName $lastName"
|
|
firstName.isNotBlank() -> firstName
|
|
lastName.isNotBlank() -> lastName
|
|
else -> username
|
|
}
|
|
|
|
// Check if user is verified - from direct field (login) OR from profile (currentUser)
|
|
val isVerified: Boolean
|
|
get() = _verified || (profile?.verified ?: false)
|
|
|
|
// Alias for backwards compatibility
|
|
val verified: Boolean
|
|
get() = isVerified
|
|
}
|
|
|
|
/**
|
|
* User profile model matching Go API UserProfileResponse
|
|
*/
|
|
@Serializable
|
|
data class UserProfile(
|
|
val id: Int,
|
|
@SerialName("user_id") val userId: Int,
|
|
val verified: Boolean = false,
|
|
val bio: String = "",
|
|
@SerialName("phone_number") val phoneNumber: String = "",
|
|
@SerialName("date_of_birth") val dateOfBirth: String? = null,
|
|
@SerialName("profile_picture") val profilePicture: String = ""
|
|
)
|
|
|
|
/**
|
|
* Register request matching Go API
|
|
*/
|
|
@Serializable
|
|
data class RegisterRequest(
|
|
val username: String,
|
|
val email: String,
|
|
val password: String,
|
|
@SerialName("first_name") val firstName: String? = null,
|
|
@SerialName("last_name") val lastName: String? = null
|
|
)
|
|
|
|
/**
|
|
* Login request matching Go API
|
|
*/
|
|
@Serializable
|
|
data class LoginRequest(
|
|
val username: String,
|
|
val password: String
|
|
)
|
|
|
|
/**
|
|
* Auth response for login - matching Go API LoginResponse
|
|
*/
|
|
@Serializable
|
|
data class AuthResponse(
|
|
val token: String,
|
|
val user: User
|
|
)
|
|
|
|
/**
|
|
* Auth response for registration - matching Go API RegisterResponse
|
|
*/
|
|
@Serializable
|
|
data class RegisterResponse(
|
|
val token: String,
|
|
val user: User,
|
|
val message: String = ""
|
|
)
|
|
|
|
/**
|
|
* Verify email request
|
|
*/
|
|
@Serializable
|
|
data class VerifyEmailRequest(
|
|
val code: String
|
|
)
|
|
|
|
/**
|
|
* Verify email response
|
|
*/
|
|
@Serializable
|
|
data class VerifyEmailResponse(
|
|
val message: String,
|
|
val verified: Boolean
|
|
)
|
|
|
|
/**
|
|
* Update profile request
|
|
*/
|
|
@Serializable
|
|
data class UpdateProfileRequest(
|
|
@SerialName("first_name") val firstName: String? = null,
|
|
@SerialName("last_name") val lastName: String? = null,
|
|
val email: String? = null
|
|
)
|
|
|
|
// Password Reset Models
|
|
|
|
@Serializable
|
|
data class ForgotPasswordRequest(
|
|
val email: String
|
|
)
|
|
|
|
@Serializable
|
|
data class ForgotPasswordResponse(
|
|
val message: String
|
|
)
|
|
|
|
@Serializable
|
|
data class VerifyResetCodeRequest(
|
|
val email: String,
|
|
val code: String
|
|
)
|
|
|
|
@Serializable
|
|
data class VerifyResetCodeResponse(
|
|
val message: String,
|
|
@SerialName("reset_token") val resetToken: String
|
|
)
|
|
|
|
@Serializable
|
|
data class ResetPasswordRequest(
|
|
@SerialName("reset_token") val resetToken: String,
|
|
@SerialName("new_password") val newPassword: String
|
|
)
|
|
|
|
@Serializable
|
|
data class ResetPasswordResponse(
|
|
val message: String
|
|
)
|
|
|
|
/**
|
|
* Generic message response used by many endpoints
|
|
*/
|
|
@Serializable
|
|
data class MessageResponse(
|
|
val message: String
|
|
)
|
|
|
|
// Apple Sign In Models
|
|
|
|
/**
|
|
* Apple Sign In request matching Go API
|
|
*/
|
|
@Serializable
|
|
data class AppleSignInRequest(
|
|
@SerialName("id_token") val idToken: String,
|
|
@SerialName("user_id") val userId: String,
|
|
val email: String? = null,
|
|
@SerialName("first_name") val firstName: String? = null,
|
|
@SerialName("last_name") val lastName: String? = null
|
|
)
|
|
|
|
/**
|
|
* Apple Sign In response matching Go API
|
|
*/
|
|
@Serializable
|
|
data class AppleSignInResponse(
|
|
val token: String,
|
|
val user: User,
|
|
@SerialName("is_new_user") val isNewUser: Boolean
|
|
)
|
|
|
|
// Google Sign In Models
|
|
|
|
/**
|
|
* Google Sign In request matching Go API
|
|
*/
|
|
@Serializable
|
|
data class GoogleSignInRequest(
|
|
@SerialName("id_token") val idToken: String
|
|
)
|
|
|
|
/**
|
|
* Google Sign In response matching Go API
|
|
*/
|
|
@Serializable
|
|
data class GoogleSignInResponse(
|
|
val token: String,
|
|
val user: User,
|
|
@SerialName("is_new_user") val isNewUser: Boolean
|
|
)
|
|
|
|
/**
|
|
* Delete account request matching Go API
|
|
*/
|
|
@Serializable
|
|
data class DeleteAccountRequest(
|
|
val password: String? = null,
|
|
val confirmation: String? = null
|
|
)
|