use actix_web::{http::StatusCode, HttpResponse, ResponseError};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum FirebaseIdpError {
#[error(
"Firebase ID token is missing `{provider}` identity provider claims"
)]
MissingIdpClaims {
provider: &'static str,
},
}
impl ResponseError for FirebaseIdpError {
fn error_response(&self) -> HttpResponse {
HttpResponse::build(self.status_code()).json(self.to_string())
}
fn status_code(&self) -> StatusCode {
match self {
FirebaseIdpError::MissingIdpClaims { .. } => {
StatusCode::UNAUTHORIZED
}
}
}
}