text
stringlengths 70
351k
| source
stringclasses 4
values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_attempts(&self) -> Option<Vec<storage::PaymentAttempt>> {
todo!()
}
fn get_recurring_details(&self) -> Option<&RecurringDetails> {
todo!()
}
fn get_payment_intent_profile_id(&self) -> Option<&id_type::ProfileId> {
Some(&self.payment_intent.profile_id)
}
fn get_currency(&self) -> storage_enums::Currency {
self.payment_intent.amount_details.currency
}
fn get_amount(&self) -> api::Amount {
todo!()
}
fn get_payment_attempt_connector(&self) -> Option<&str> {
todo!()
}
fn get_merchant_connector_id_in_attempt(&self) -> Option<id_type::MerchantConnectorAccountId> {
fn get_currency(&self) -> storage_enums::Currency {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_refunds(&self) -> Vec<storage::Refund> {
todo!()
}
fn get_disputes(&self) -> Vec<storage::Dispute> {
todo!()
}
fn get_authorizations(&self) -> Vec<diesel_models::authorization::Authorization> {
todo!()
}
fn get_attempts(&self) -> Option<Vec<storage::PaymentAttempt>> {
todo!()
}
fn get_recurring_details(&self) -> Option<&RecurringDetails> {
todo!()
}
fn get_payment_intent_profile_id(&self) -> Option<&id_type::ProfileId> {
Some(&self.payment_intent.profile_id)
}
fn get_currency(&self) -> storage_enums::Currency {
fn get_attempts(&self) -> Option<Vec<storage::PaymentAttempt>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_authentication(&self) -> Option<&storage::Authentication> {
todo!()
}
fn get_frm_message(&self) -> Option<FraudCheck> {
todo!()
}
fn get_refunds(&self) -> Vec<storage::Refund> {
todo!()
}
fn get_disputes(&self) -> Vec<storage::Dispute> {
todo!()
}
fn get_authorizations(&self) -> Vec<diesel_models::authorization::Authorization> {
todo!()
}
fn get_attempts(&self) -> Option<Vec<storage::PaymentAttempt>> {
todo!()
}
fn get_recurring_details(&self) -> Option<&RecurringDetails> {
fn get_disputes(&self) -> Vec<storage::Dispute> {
todo!()
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
fn get_poll_config(&self) -> Option<router_types::PollConfig> {
todo!()
}
fn get_authentication(&self) -> Option<&storage::Authentication> {
todo!()
}
fn get_frm_message(&self) -> Option<FraudCheck> {
todo!()
}
fn get_refunds(&self) -> Vec<storage::Refund> {
todo!()
}
fn get_disputes(&self) -> Vec<storage::Dispute> {
todo!()
}
fn get_authorizations(&self) -> Vec<diesel_models::authorization::Authorization> {
fn get_frm_message(&self) -> Option<FraudCheck> {
todo!()
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}
fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
fn get_poll_config(&self) -> Option<router_types::PollConfig> {
todo!()
}
fn get_authentication(&self) -> Option<&storage::Authentication> {
todo!()
}
fn get_frm_message(&self) -> Option<FraudCheck> {
todo!()
}
fn get_refunds(&self) -> Vec<storage::Refund> {
todo!()
}
fn get_disputes(&self) -> Vec<storage::Dispute> {
fn get_authentication(&self) -> Option<&storage::Authentication> {
todo!()
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse> {
todo!()
}
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}
fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
fn get_poll_config(&self) -> Option<router_types::PollConfig> {
todo!()
}
fn get_authentication(&self) -> Option<&storage::Authentication> {
todo!()
}
fn get_frm_message(&self) -> Option<FraudCheck> {
todo!()
}
fn get_refunds(&self) -> Vec<storage::Refund> {
fn get_poll_config(&self) -> Option<router_types::PollConfig> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData> {
todo!()
}
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse> {
todo!()
}
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}
fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
fn get_poll_config(&self) -> Option<router_types::PollConfig> {
todo!()
}
fn get_authentication(&self) -> Option<&storage::Authentication> {
todo!()
}
fn get_frm_message(&self) -> Option<FraudCheck> {
fn get_setup_mandate(&self) -> Option<&MandateData> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_token(&self) -> Option<&str> {
todo!()
}
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData> {
todo!()
}
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse> {
todo!()
}
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}
fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
fn get_poll_config(&self) -> Option<router_types::PollConfig> {
todo!()
}
fn get_authentication(&self) -> Option<&storage::Authentication> {
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
todo!()
}
// what is this address find out and not required remove this
fn get_address(&self) -> &PaymentAddress {
todo!()
}
fn get_creds_identifier(&self) -> Option<&str> {
None
}
fn get_token(&self) -> Option<&str> {
todo!()
}
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData> {
todo!()
}
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse> {
todo!()
}
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
fn get_token(&self) -> Option<&str> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
todo!()
}
fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
todo!()
}
// what is this address find out and not required remove this
fn get_address(&self) -> &PaymentAddress {
todo!()
}
fn get_creds_identifier(&self) -> Option<&str> {
None
}
fn get_token(&self) -> Option<&str> {
todo!()
}
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData> {
todo!()
}
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse> {
fn get_creds_identifier(&self) -> Option<&str> {
None
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
&self.payment_intent
}
fn get_payment_method_info(&self) -> Option<&domain::PaymentMethod> {
todo!()
}
fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
todo!()
}
// what is this address find out and not required remove this
fn get_address(&self) -> &PaymentAddress {
todo!()
}
fn get_creds_identifier(&self) -> Option<&str> {
None
}
fn get_token(&self) -> Option<&str> {
todo!()
}
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData> {
fn get_address(&self) -> &PaymentAddress {
todo!()
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_payment_attempt(&self) -> &storage::PaymentAttempt {
&self.payment_attempt
}
fn get_payment_intent(&self) -> &storage::PaymentIntent {
&self.payment_intent
}
fn get_payment_method_info(&self) -> Option<&domain::PaymentMethod> {
todo!()
}
fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
todo!()
}
// what is this address find out and not required remove this
fn get_address(&self) -> &PaymentAddress {
todo!()
}
fn get_creds_identifier(&self) -> Option<&str> {
None
}
fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
) {
self.payment_intent.setup_future_usage = setup_future_usage;
}
fn set_connector_in_payment_attempt(&mut self, connector: Option<String>) {
todo!()
}
}
#[cfg(feature = "v2")]
impl<F: Clone> OperationSessionGetters<F> for PaymentCaptureData<F> {
#[track_caller]
fn get_payment_attempt(&self) -> &storage::PaymentAttempt {
&self.payment_attempt
}
fn get_payment_intent(&self) -> &storage::PaymentIntent {
&self.payment_intent
}
fn get_payment_method_info(&self) -> Option<&domain::PaymentMethod> {
todo!()
}
fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
fn get_payment_attempt(&self) -> &storage::PaymentAttempt {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_recurring_mandate_payment_data(
&mut self,
_recurring_mandate_payment_data:
hyperswitch_domain_models::router_data::RecurringMandatePaymentData,
) {
todo!()
}
fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
todo!()
}
fn set_setup_future_usage_in_payment_intent(
&mut self,
setup_future_usage: storage_enums::FutureUsage,
) {
self.payment_intent.setup_future_usage = setup_future_usage;
}
fn set_connector_in_payment_attempt(&mut self, connector: Option<String>) {
todo!()
}
}
#[cfg(feature = "v2")]
fn set_setup_future_usage_in_payment_intent(
&mut self,
setup_future_usage: storage_enums::FutureUsage,
) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
) {
todo!()
}
fn set_recurring_mandate_payment_data(
&mut self,
_recurring_mandate_payment_data:
hyperswitch_domain_models::router_data::RecurringMandatePaymentData,
) {
todo!()
}
fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
todo!()
}
fn set_setup_future_usage_in_payment_intent(
&mut self,
setup_future_usage: storage_enums::FutureUsage,
) {
self.payment_intent.setup_future_usage = setup_future_usage;
}
fn set_connector_in_payment_attempt(&mut self, connector: Option<String>) {
todo!()
fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus) {
self.payment_intent.status = status;
}
fn set_authentication_type_in_attempt(
&mut self,
_authentication_type: Option<enums::AuthenticationType>,
) {
todo!()
}
fn set_recurring_mandate_payment_data(
&mut self,
_recurring_mandate_payment_data:
hyperswitch_domain_models::router_data::RecurringMandatePaymentData,
) {
todo!()
}
fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
todo!()
}
fn set_setup_future_usage_in_payment_intent(
fn set_recurring_mandate_payment_data(
&mut self,
_recurring_mandate_payment_data:
hyperswitch_domain_models::router_data::RecurringMandatePaymentData,
) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
#[track_caller]
fn set_merchant_connector_id_in_attempt(
&mut self,
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
) {
todo!()
}
fn set_frm_message(&mut self, _frm_message: FraudCheck) {
todo!()
}
fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus) {
self.payment_intent.status = status;
}
fn set_authentication_type_in_attempt(
&mut self,
_authentication_type: Option<enums::AuthenticationType>,
) {
todo!()
}
fn set_recurring_mandate_payment_data(
&mut self,
fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_surcharge_details(&mut self, _surcharge_details: Option<types::SurchargeDetails>) {
todo!()
}
#[track_caller]
fn set_merchant_connector_id_in_attempt(
&mut self,
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
) {
todo!()
}
fn set_frm_message(&mut self, _frm_message: FraudCheck) {
todo!()
}
fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus) {
self.payment_intent.status = status;
}
fn set_authentication_type_in_attempt(
&mut self,
_authentication_type: Option<enums::AuthenticationType>,
) {
todo!()
fn set_frm_message(&mut self, _frm_message: FraudCheck) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_mandate_connector(&self) -> Option<&MandateConnectorDetails> {
todo!()
}
fn get_force_sync(&self) -> Option<bool> {
todo!()
}
fn get_capture_method(&self) -> Option<enums::CaptureMethod> {
todo!()
}
fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> {
self.payment_attempt.as_ref()
}
}
#[cfg(feature = "v2")]
impl<F: Clone> OperationSessionSetters<F> for PaymentStatusData<F> {
fn set_payment_intent(&mut self, payment_intent: storage::PaymentIntent) {
self.payment_intent = payment_intent;
}
fn set_payment_attempt(&mut self, payment_attempt: storage::PaymentAttempt) {
self.payment_attempt = Some(payment_attempt);
fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_amount(&self) -> api::Amount {
todo!()
}
fn get_payment_attempt_connector(&self) -> Option<&str> {
todo!()
}
fn get_merchant_connector_id_in_attempt(&self) -> Option<id_type::MerchantConnectorAccountId> {
todo!()
}
fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {
todo!()
}
fn get_payment_method_data(&self) -> Option<&domain::PaymentMethodData> {
todo!()
}
fn get_sessions_token(&self) -> Vec<api::SessionToken> {
todo!()
}
fn get_token_data(&self) -> Option<&storage::PaymentTokenData> {
fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_recurring_details(&self) -> Option<&RecurringDetails> {
todo!()
}
fn get_payment_intent_profile_id(&self) -> Option<&id_type::ProfileId> {
Some(&self.payment_intent.profile_id)
}
fn get_currency(&self) -> storage_enums::Currency {
self.payment_intent.amount_details.currency
}
fn get_amount(&self) -> api::Amount {
todo!()
}
fn get_payment_attempt_connector(&self) -> Option<&str> {
todo!()
}
fn get_merchant_connector_id_in_attempt(&self) -> Option<id_type::MerchantConnectorAccountId> {
todo!()
}
fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {
fn get_amount(&self) -> api::Amount {
todo!()
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_disputes(&self) -> Vec<storage::Dispute> {
todo!()
}
fn get_authorizations(&self) -> Vec<diesel_models::authorization::Authorization> {
todo!()
}
fn get_attempts(&self) -> Option<Vec<storage::PaymentAttempt>> {
todo!()
}
fn get_recurring_details(&self) -> Option<&RecurringDetails> {
todo!()
}
fn get_payment_intent_profile_id(&self) -> Option<&id_type::ProfileId> {
Some(&self.payment_intent.profile_id)
}
fn get_currency(&self) -> storage_enums::Currency {
self.payment_intent.amount_details.currency
}
fn get_amount(&self) -> api::Amount {
fn get_recurring_details(&self) -> Option<&RecurringDetails> {
todo!()
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_frm_message(&self) -> Option<FraudCheck> {
todo!()
}
fn get_refunds(&self) -> Vec<storage::Refund> {
todo!()
}
fn get_disputes(&self) -> Vec<storage::Dispute> {
todo!()
}
fn get_authorizations(&self) -> Vec<diesel_models::authorization::Authorization> {
todo!()
}
fn get_attempts(&self) -> Option<Vec<storage::PaymentAttempt>> {
todo!()
}
fn get_recurring_details(&self) -> Option<&RecurringDetails> {
todo!()
}
fn get_payment_intent_profile_id(&self) -> Option<&id_type::ProfileId> {
fn get_authorizations(&self) -> Vec<diesel_models::authorization::Authorization> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_authentication(&self) -> Option<&storage::Authentication> {
todo!()
}
fn get_frm_message(&self) -> Option<FraudCheck> {
todo!()
}
fn get_refunds(&self) -> Vec<storage::Refund> {
todo!()
}
fn get_disputes(&self) -> Vec<storage::Dispute> {
todo!()
}
fn get_authorizations(&self) -> Vec<diesel_models::authorization::Authorization> {
todo!()
}
fn get_attempts(&self) -> Option<Vec<storage::PaymentAttempt>> {
todo!()
}
fn get_recurring_details(&self) -> Option<&RecurringDetails> {
fn get_disputes(&self) -> Vec<storage::Dispute> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_poll_config(&self) -> Option<router_types::PollConfig> {
todo!()
}
fn get_authentication(&self) -> Option<&storage::Authentication> {
todo!()
}
fn get_frm_message(&self) -> Option<FraudCheck> {
todo!()
}
fn get_refunds(&self) -> Vec<storage::Refund> {
todo!()
}
fn get_disputes(&self) -> Vec<storage::Dispute> {
todo!()
}
fn get_authorizations(&self) -> Vec<diesel_models::authorization::Authorization> {
todo!()
}
fn get_attempts(&self) -> Option<Vec<storage::PaymentAttempt>> {
fn get_refunds(&self) -> Vec<storage::Refund> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}
fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
fn get_poll_config(&self) -> Option<router_types::PollConfig> {
todo!()
}
fn get_authentication(&self) -> Option<&storage::Authentication> {
todo!()
}
fn get_frm_message(&self) -> Option<FraudCheck> {
todo!()
}
fn get_refunds(&self) -> Vec<storage::Refund> {
todo!()
}
fn get_disputes(&self) -> Vec<storage::Dispute> {
fn get_authentication(&self) -> Option<&storage::Authentication> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_creds_identifier(&self) -> Option<&str> {
None
}
fn get_token(&self) -> Option<&str> {
todo!()
}
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData> {
todo!()
}
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse> {
todo!()
}
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}
fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
fn get_poll_config(&self) -> Option<router_types::PollConfig> {
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_address(&self) -> &PaymentAddress {
&self.payment_address
}
fn get_creds_identifier(&self) -> Option<&str> {
None
}
fn get_token(&self) -> Option<&str> {
todo!()
}
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData> {
todo!()
}
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse> {
todo!()
}
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}
fn get_setup_mandate(&self) -> Option<&MandateData> {
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_payment_method_info(&self) -> Option<&domain::PaymentMethod> {
todo!()
}
fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
todo!()
}
fn get_address(&self) -> &PaymentAddress {
&self.payment_address
}
fn get_creds_identifier(&self) -> Option<&str> {
None
}
fn get_token(&self) -> Option<&str> {
todo!()
}
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData> {
todo!()
}
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse> {
fn get_creds_identifier(&self) -> Option<&str> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
#[cfg(feature = "v2")]
impl<F: Clone> OperationSessionGetters<F> for PaymentStatusData<F> {
#[track_caller]
fn get_payment_attempt(&self) -> &storage::PaymentAttempt {
todo!()
}
fn get_payment_intent(&self) -> &storage::PaymentIntent {
&self.payment_intent
}
fn get_payment_method_info(&self) -> Option<&domain::PaymentMethod> {
todo!()
}
fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
todo!()
}
fn get_address(&self) -> &PaymentAddress {
&self.payment_address
}
fn get_creds_identifier(&self) -> Option<&str> {
fn get_payment_method_info(&self) -> Option<&domain::PaymentMethod> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_connector_in_payment_attempt(&mut self, connector: Option<String>) {
self.payment_attempt.connector = connector;
}
}
#[cfg(feature = "v2")]
impl<F: Clone> OperationSessionGetters<F> for PaymentStatusData<F> {
#[track_caller]
fn get_payment_attempt(&self) -> &storage::PaymentAttempt {
todo!()
}
fn get_payment_intent(&self) -> &storage::PaymentIntent {
&self.payment_intent
}
fn get_payment_method_info(&self) -> Option<&domain::PaymentMethod> {
todo!()
}
fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
todo!()
}
fn get_address(&self) -> &PaymentAddress {
fn get_payment_intent(&self) -> &storage::PaymentIntent {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
) {
self.payment_attempt.merchant_connector_id = merchant_connector_id;
}
fn set_frm_message(&mut self, _frm_message: FraudCheck) {
todo!()
}
fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus) {
self.payment_intent.status = status;
}
fn set_authentication_type_in_attempt(
&mut self,
_authentication_type: Option<enums::AuthenticationType>,
) {
todo!()
}
fn set_recurring_mandate_payment_data(
&mut self,
_recurring_mandate_payment_data:
hyperswitch_domain_models::router_data::RecurringMandatePaymentData,
) {
todo!()
fn set_authentication_type_in_attempt(
&mut self,
_authentication_type: Option<enums::AuthenticationType>,
) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
#[track_caller]
fn set_merchant_connector_id_in_attempt(
&mut self,
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
) {
self.payment_attempt.merchant_connector_id = merchant_connector_id;
}
fn set_frm_message(&mut self, _frm_message: FraudCheck) {
todo!()
}
fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus) {
self.payment_intent.status = status;
}
fn set_authentication_type_in_attempt(
&mut self,
_authentication_type: Option<enums::AuthenticationType>,
) {
todo!()
}
fn set_recurring_mandate_payment_data(
&mut self,
fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus) {
self.payment_intent.status = status;
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_payment_method_data(&mut self, _payment_method_data: Option<domain::PaymentMethodData>) {
todo!()
}
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
todo!()
}
fn set_email_if_not_present(&mut self, _email: pii::Email) {
todo!()
}
fn set_pm_token(&mut self, _token: String) {
todo!()
}
fn set_connector_customer_id(&mut self, _customer_id: Option<String>) {
// TODO: handle this case. Should we add connector_customer_id in paymentConfirmData?
}
fn push_sessions_token(&mut self, _token: api::SessionToken) {
todo!()
}
fn set_surcharge_details(&mut self, _surcharge_details: Option<types::SurchargeDetails>) {
fn set_pm_token(&mut self, _token: String) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_payment_attempt(&mut self, payment_attempt: storage::PaymentAttempt) {
self.payment_attempt = payment_attempt;
}
fn set_payment_method_data(&mut self, _payment_method_data: Option<domain::PaymentMethodData>) {
todo!()
}
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
todo!()
}
fn set_email_if_not_present(&mut self, _email: pii::Email) {
todo!()
}
fn set_pm_token(&mut self, _token: String) {
todo!()
}
fn set_connector_customer_id(&mut self, _customer_id: Option<String>) {
// TODO: handle this case. Should we add connector_customer_id in paymentConfirmData?
}
fn push_sessions_token(&mut self, _token: api::SessionToken) {
fn set_email_if_not_present(&mut self, _email: pii::Email) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_capture_method(&self) -> Option<enums::CaptureMethod> {
todo!()
}
fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> {
Some(&self.payment_attempt)
}
}
#[cfg(feature = "v2")]
impl<F: Clone> OperationSessionSetters<F> for PaymentConfirmData<F> {
// Setters Implementation
fn set_payment_intent(&mut self, payment_intent: storage::PaymentIntent) {
self.payment_intent = payment_intent;
}
fn set_payment_attempt(&mut self, payment_attempt: storage::PaymentAttempt) {
self.payment_attempt = payment_attempt;
}
fn set_payment_method_data(&mut self, _payment_method_data: Option<domain::PaymentMethodData>) {
todo!()
}
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
fn set_payment_intent(&mut self, payment_intent: storage::PaymentIntent) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_sessions_token(&self) -> Vec<api::SessionToken> {
todo!()
}
fn get_token_data(&self) -> Option<&storage::PaymentTokenData> {
todo!()
}
fn get_mandate_connector(&self) -> Option<&MandateConnectorDetails> {
todo!()
}
fn get_force_sync(&self) -> Option<bool> {
todo!()
}
fn get_capture_method(&self) -> Option<enums::CaptureMethod> {
todo!()
}
fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> {
Some(&self.payment_attempt)
}
}
fn get_force_sync(&self) -> Option<bool> {
todo!()
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use std::collections::HashMap;
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use common_utils::ext_traits::{Encode, ValueExt};
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn get_aggregates_for_disputes(
state: SessionState,
merchant: domain::MerchantAccount,
profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,
time_range: common_utils::types::TimeRange,
) -> RouterResponse<dispute_models::DisputesAggregateResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn delete_evidence(
state: SessionState,
merchant_account: domain::MerchantAccount,
delete_evidence_request: dispute_models::DeleteEvidenceRequest,
) -> RouterResponse<serde_json::Value> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use common_utils::ext_traits::{Encode, ValueExt};
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn attach_evidence(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id: Option<common_utils::id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
attach_evidence_request: api::AttachEvidenceRequest,
) -> RouterResponse<files_api_models::CreateFileResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use std::collections::HashMap;
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use common_utils::ext_traits::{Encode, ValueExt};
use error_stack::ResultExt;
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn get_filters_for_disputes(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,
) -> RouterResponse<api_models::disputes::DisputeListFilters> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
.update_dispute(dispute.clone(), update_dispute)
.await
.to_not_found_response(errors::ApiErrorResponse::DisputeNotFound {
dispute_id: dispute_id.to_owned(),
})
.attach_printable_lazy(|| {
format!("Unable to update dispute with dispute_id: {dispute_id}")
})?;
let dispute_response = api_models::disputes::DisputeResponse::foreign_from(updated_dispute);
Ok(services::ApplicationResponse::Json(dispute_response))
}
pub async fn attach_evidence(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id: Option<common_utils::id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
attach_evidence_request: api::AttachEvidenceRequest,
) -> RouterResponse<files_api_models::CreateFileResponse> {
let db = &state.store;
let dispute_id = attach_evidence_request
.create_file_request
.dispute_id
.clone()
.ok_or(errors::ApiErrorResponse::MissingDisputeId)?;
pub async fn attach_evidence(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id: Option<common_utils::id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
attach_evidence_request: api::AttachEvidenceRequest,
) -> RouterResponse<files_api_models::CreateFileResponse> {
{
services::ApplicationResponse::Json(res) => res.file_id.clone(),<|fim_suffix|>
<|fim_middle|>
_ => Err(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unexpected response received from files create core")?,
}
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use common_utils::ext_traits::{Encode, ValueExt};
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn retrieve_dispute_evidence(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id: Option<common_utils::id_type::ProfileId>,
req: disputes::DisputeId,
) -> RouterResponse<Vec<api_models::disputes::DisputeEvidenceBlock>> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use common_utils::ext_traits::{Encode, ValueExt};
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn submit_evidence(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id: Option<common_utils::id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
req: dispute_models::SubmitEvidenceRequest,
) -> RouterResponse<dispute_models::DisputeResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use common_utils::ext_traits::{Encode, ValueExt};
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn accept_dispute(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id: Option<common_utils::id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
req: disputes::DisputeId,
) -> RouterResponse<dispute_models::DisputeResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use common_utils::ext_traits::{Encode, ValueExt};
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn retrieve_disputes_list(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,
constraints: api_models::disputes::DisputeListGetConstraints,
) -> RouterResponse<Vec<api_models::disputes::DisputeResponse>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use common_utils::ext_traits::{Encode, ValueExt};
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn retrieve_dispute(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id: Option<common_utils::id_type::ProfileId>,
req: disputes::DisputeId,
) -> RouterResponse<api_models::disputes::DisputeResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/disputes.rs | crate: router
use api_models::{
admin::MerchantConnectorInfo, disputes as dispute_models, files as files_api_models,
};
use common_utils::ext_traits::{Encode, ValueExt};
use super::{
errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},
metrics,
};
use crate::{
core::{files, payments, utils as core_utils},
routes::SessionState,
services,
types::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
};
pub async fn submit_evidence(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id: Option<common_utils::id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
req: dispute_models::SubmitEvidenceRequest,
) -> RouterResponse<dispute_models::DisputeResponse> {
{let db = &state.store;<|fim_suffix|>
<|fim_middle|>
Ok(services::ApplicationResponse::Json(dispute_response))}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use std::{
collections::{HashMap, HashSet},
ops::Not,
};
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn list_merchants_for_user_in_org(
state: SessionState,
user_from_token: auth::UserFromToken,
) -> UserResponse<Vec<user_api::UserMerchantAccountResponse>> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use std::{
collections::{HashMap, HashSet},
ops::Not,
};
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn list_orgs_for_user(
state: SessionState,
user_from_token: auth::UserFromToken,
) -> UserResponse<Vec<user_api::ListOrgsForUserResponse>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn terminate_auth_select(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
req: user_api::AuthSelectRequest,
) -> UserResponse<user_api::TokenResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use masking::{ExposeInterface, PeekInterface, Secret};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn get_sso_auth_url(
state: SessionState,
request: user_api::GetSsoAuthUrlRequest,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use error_stack::{report, ResultExt};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn list_user_authentication_methods(
state: SessionState,
req: user_api::GetUserAuthenticationMethodsRequest,
) -> UserResponse<Vec<user_api::UserAuthenticationMethodResponse>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn check_two_factor_auth_status_with_attempts(
state: SessionState,
user_token: auth::UserIdFromAuth,
) -> UserResponse<user_api::TwoFactorStatus> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn terminate_two_factor_auth(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
skip_two_factor_auth: bool,
) -> UserResponse<user_api::TokenResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn verify_recovery_code(
state: SessionState,
user_token: auth::UserIdFromAuth,
req: user_api::VerifyRecoveryCodeRequest,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn generate_recovery_codes(
state: SessionState,
user_token: auth::UserIdFromAuth,
) -> UserResponse<user_api::RecoveryCodes> {
if !tfa_utils::check_totp_in_redis(&state, &user_token.user_id).await? {
return Err(UserErrors::TotpRequired.into());
}
let recovery_codes = domain::RecoveryCodes::generate_new();
state
.global_store
.update_user_by_user_id(
&user_token.user_id,
storage_user::UserUpdate::TotpUpdate {
totp_status: None,
totp_secret: None,
totp_recovery_codes: Some(
recovery_codes
.get_hashed()
.change_context(UserErrors::InternalServerError)?,
),
},
)
.await
.change_context(UserErrors::InternalServerError)?;
Ok(ApplicationResponse::Json(user_api::RecoveryCodes {
recovery_codes: recovery_codes.into_inner(),
}))
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use masking::{ExposeInterface, PeekInterface, Secret};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::types::transformers::ForeignFrom;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn update_totp(
state: SessionState,
user_token: auth::UserIdFromAuth,
req: user_api::VerifyTotpRequest,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn verify_totp(
state: SessionState,
user_token: auth::UserIdFromAuth,
req: user_api::VerifyTotpRequest,
) -> UserResponse<user_api::TokenResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn reset_totp(
state: SessionState,
user_token: auth::UserFromToken,
) -> UserResponse<user_api::BeginTotpResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn begin_totp(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
) -> UserResponse<user_api::BeginTotpResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn user_from_email(
state: SessionState,
req: user_api::UserFromEmailRequest,
) -> UserResponse<user_api::TokenResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn update_user_details(
state: SessionState,
user_token: auth::UserFromToken,
req: user_api::UpdateUserAccountDetailsRequest,
_req_state: ReqState,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn send_verification_mail(
state: SessionState,
req: user_api::SendVerifyEmailRequest,
auth_id: Option<String>,
theme_id: Option<String>,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn verify_email_token_only_flow(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
req: user_api::VerifyEmailRequest,
) -> UserResponse<user_api::TokenResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn create_tenant_user(
state: SessionState,
request: user_api::CreateTenantUserRequest,
) -> UserResponse<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use error_stack::{report, ResultExt};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
async fn handle_invitation(
state: &SessionState,
user_from_token: &auth::UserFromToken,
request: &user_api::InviteUserRequest,
req_state: &ReqState,
auth_id: &Option<String>,
) -> UserResult<InviteMultipleUserResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use error_stack::{report, ResultExt};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn invite_multiple_user(
state: SessionState,
user_from_token: auth::UserFromToken,
requests: Vec<user_api::InviteUserRequest>,
req_state: ReqState,
auth_id: Option<String>,
) -> UserResponse<Vec<InviteMultipleUserResponse>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn reset_password_token_only_flow(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
request: user_api::ResetPasswordRequest,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn rotate_password(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
request: user_api::RotatePasswordRequest,
_req_state: ReqState,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn forgot_password(
state: SessionState,
request: user_api::ForgotPasswordRequest,
auth_id: Option<String>,
theme_id: Option<String>,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn change_password(
state: SessionState,
request: user_api::ChangePasswordRequest,
user_from_token: auth::UserFromToken,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn signin_token_only_flow(
state: SessionState,
request: user_api::SignInRequest,
) -> UserResponse<user_api::TokenResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn signup_token_only_flow(
state: SessionState,
request: user_api::SignUpRequest,
) -> UserResponse<user_api::TokenResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn signup_with_merchant_id(
state: SessionState,
request: user_api::SignUpWithMerchantIdRequest,
auth_id: Option<String>,
theme_id: Option<String>,
) -> UserResponse<user_api::SignUpWithMerchantIdResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
domain::NextFlow::from_origin(domain::Origin::SignInWithSSO, user_from_db, &state).await?
};
let token = next_flow.get_token(&state).await?;
let response = user_api::TokenResponse {
token: token.clone(),
token_type: next_flow.get_flow().into(),
};
auth::cookies::set_cookie_response(response, token)
}
pub async fn terminate_auth_select(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
req: user_api::AuthSelectRequest,
) -> UserResponse<user_api::TokenResponse> {
let user_from_db: domain::UserFromStorage = state
.global_store
.find_user_by_id(&user_token.user_id)
.await
.change_context(UserErrors::InternalServerError)?
.into();
let user_email = domain::UserEmail::from_pii_email(user_from_db.get_email())?;
pub async fn terminate_auth_select(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
req: user_api::AuthSelectRequest,
) -> UserResponse<user_api::TokenResponse> {
{
(Some(id), _) => auth_methods
.into_iter()
.find(|auth_method| auth_method.id == id)
.ok_or(UserErrors::InvalidUserAuthMethodOperation)?,<|fim_suffix|>
<|fim_middle|>
(None, false) => return Err(UserErrors::InvalidUserAuthMethodOperation.into()),
}
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
.await
.inspect_err(|error| logger::error!(?error));
auth::cookies::set_cookie_response(
user_api::TokenResponse {
token: token.clone(),
token_type: next_flow.get_flow().into(),
},
token,
)
}
pub async fn check_two_factor_auth_status(
state: SessionState,
user_token: auth::UserFromToken,
) -> UserResponse<user_api::TwoFactorAuthStatusResponse> {
Ok(ApplicationResponse::Json(
user_api::TwoFactorAuthStatusResponse {
totp: tfa_utils::check_totp_in_redis(&state, &user_token.user_id).await?,
recovery_code: tfa_utils::check_recovery_code_in_redis(&state, &user_token.user_id)
.await?,
},
))
}
pub async fn check_two_factor_auth_status(
state: SessionState,
user_token: auth::UserFromToken,
) -> UserResponse<user_api::TwoFactorAuthStatusResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn check_two_factor_auth_status(
state: SessionState,
user_token: auth::UserFromToken,
) -> UserResponse<user_api::TwoFactorAuthStatusResponse> {
Ok(ApplicationResponse::Json(
user_api::TwoFactorAuthStatusResponse {
totp: tfa_utils::check_totp_in_redis(&state, &user_token.user_id).await?,
recovery_code: tfa_utils::check_recovery_code_in_redis(&state, &user_token.user_id)
.await?,
},
))
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn transfer_user_key_store_keymanager(
state: SessionState,
req: user_api::UserKeyTransferRequest,
) -> UserResponse<user_api::UserTransferKeyResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn create_merchant_account(
state: SessionState,
user_from_token: auth::UserFromToken,
req: user_api::UserMerchantCreate,
) -> UserResponse<user_api::UserMerchantAccountResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::admin;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::types::transformers::ForeignFrom;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn create_org_merchant_for_user(
state: SessionState,
req: user_api::UserOrgMerchantCreateRequest,
) -> UserResponse<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn signout(
state: SessionState,
user_from_token: auth::UserIdFromAuth,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn switch_profile_for_user_in_org_and_merchant(
state: SessionState,
request: user_api::SwitchProfileRequest,
user_from_token: auth::UserFromToken,
) -> UserResponse<user_api::TokenResponse> {
if user_from_token.profile_id == request.profile_id {
return Err(UserErrors::InvalidRoleOperationWithMessage(
"User switching to same profile".to_string(),
)
.into());
}
let key_manager_state = &(&state).into();
let role_info = roles::RoleInfo::from_role_id_org_id_tenant_id(
&state,
&user_from_token.role_id,
&user_from_token.org_id,
user_from_token
.tenant_id
.as_ref()
.unwrap_or(&state.tenant.tenant_id),
)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to retrieve role information")?;
let (profile_id, role_id) = match role_info.get_entity_type() {
EntityType::Tenant | EntityType::Organization | EntityType::Merchant => {
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
key_manager_state,
&user_from_token.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to retrieve merchant key store by merchant_id")?;
let profile_id = state
.store
.find_business_profile_by_merchant_id_profile_id(
key_manager_state,
&merchant_key_store,
&user_from_token.merchant_id,
&request.profile_id,
)
.await
.change_context(UserErrors::InvalidRoleOperationWithMessage(
"No such profile found for the merchant".to_string(),
))?
.get_id()
.to_owned();
(profile_id, user_from_token.role_id)
}
EntityType::Profile => {
let user_role = state
.global_store
.list_user_roles_by_user_id(ListUserRolesByUserIdPayload{
user_id:&user_from_token.user_id,
tenant_id: user_from_token
.tenant_id
.as_ref()
.unwrap_or(&state.tenant.tenant_id),
org_id: Some(&user_from_token.org_id),
merchant_id: Some(&user_from_token.merchant_id),
profile_id:Some(&request.profile_id),
entity_id: None,
version:None,
status: Some(UserStatus::Active),
limit: Some(1)
}
)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to list user roles for the given user_id, org_id, merchant_id and profile_id")?
.pop()
.ok_or(UserErrors::InvalidRoleOperationWithMessage(
"No user role associated with the profile".to_string(),
))?;
(request.profile_id, user_role.role_id)
}
};
let token = utils::user::generate_jwt_auth_token_with_attributes(
&state,
user_from_token.user_id,
user_from_token.merchant_id.clone(),
user_from_token.org_id.clone(),
role_id.clone(),
profile_id,
user_from_token.tenant_id.clone(),
)
.await?;
utils::user_role::set_role_info_in_cache_by_role_id_org_id(
&state,
&role_id,
&user_from_token.org_id,
user_from_token
.tenant_id
.as_ref()
.unwrap_or(&state.tenant.tenant_id),
)
.await;
let response = user_api::TokenResponse {
token: token.clone(),
token_type: common_enums::TokenPurpose::UserInfo,
};
auth::cookies::set_cookie_response(response, token)
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn switch_org_for_user(
state: SessionState,
request: user_api::SwitchOrganizationRequest,
user_from_token: auth::UserFromToken,
) -> UserResponse<user_api::TokenResponse> {
{
EntityType::Tenant => {
let merchant_id = state
.store
.list_merchant_accounts_by_organization_id(&(&state).into(), &request.org_id)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to get merchant list for org")?
.pop()
.ok_or(UserErrors::InvalidRoleOperation)
.attach_printable("No merchants found for the org id")?
.get_id()
.to_owned();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
&(&state).into(),
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
.await
.change_context(UserErrors::InternalServerError)?;
let profile_id = state
.store
.list_profile_by_merchant_id(&(&state).into(), &key_store, &merchant_id)
.await
.change_context(UserErrors::InternalServerError)?
.pop()
.ok_or(UserErrors::InternalServerError)?
.get_id()
.to_owned();
(merchant_id, profile_id, user_from_token.role_id)
}<|fim_suffix|>
<|fim_middle|>
EntityType::Organization | EntityType::Merchant | EntityType::Profile => {
let user_role = state
.global_store
.list_user_roles_by_user_id(ListUserRolesByUserIdPayload {
user_id: &user_from_token.user_id,
tenant_id: user_from_token
.tenant_id
.as_ref()
.unwrap_or(&state.tenant.tenant_id),
org_id: Some(&request.org_id),
merchant_id: None,
profile_id: None,
entity_id: None,
version: None,
status: Some(UserStatus::Active),
limit: Some(1),
})
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to list user roles by user_id and org_id")?
.pop()
.ok_or(UserErrors::InvalidRoleOperationWithMessage(
"No user role found for the requested org_id".to_string(),
))?;
let (merchant_id, profile_id) =
utils::user_role::get_single_merchant_id_and_profile_id(&state, &user_role).await?;
(merchant_id, profile_id, user_role.role_id)
}
}
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use std::{
collections::{HashMap, HashSet},
ops::Not,
};
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn list_profiles_for_user_in_org_and_merchant_account(
state: SessionState,
user_from_token: auth::UserFromToken,
) -> UserResponse<Vec<user_api::ListProfilesForUserInOrgAndMerchantAccountResponse>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn sso_sign(
state: SessionState,
request: user_api::SsoSignInRequest,
user_from_single_purpose_token: Option<auth::UserFromSinglePurposeToken>,
) -> UserResponse<user_api::TokenResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use storage_impl::errors::StorageError;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn update_user_authentication_method(
state: SessionState,
req: user_api::UpdateUserAuthenticationMethodRequest,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use error_stack::{report, ResultExt};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn create_user_authentication_method(
state: SessionState,
req: user_api::CreateUserAuthenticationMethodRequest,
) -> UserResponse<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn create_internal_user(
state: SessionState,
request: user_api::CreateInternalUserRequest,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use error_stack::{report, ResultExt};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn accept_invite_from_email_token_only_flow(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
request: user_api::AcceptInviteFromEmailRequest,
) -> UserResponse<user_api::TokenResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use error_stack::{report, ResultExt};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn resend_invite(
state: SessionState,
user_from_token: auth::UserFromToken,
request: user_api::ReInviteUserRequest,
auth_id: Option<String>,
) -> UserResponse<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use error_stack::{report, ResultExt};
use router_env::env;
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn connect_account(
state: SessionState,
request: user_api::ConnectAccountRequest,
auth_id: Option<String>,
theme_id: Option<String>,
) -> UserResponse<user_api::ConnectAccountResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn get_user_details(
state: SessionState,
user_from_token: auth::UserFromToken,
) -> UserResponse<user_api::GetUserDetailsResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::types::transformers::ForeignFrom;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn switch_merchant_for_user_in_org(
state: SessionState,
request: user_api::SwitchMerchantRequest,
user_from_token: auth::UserFromToken,
) -> UserResponse<user_api::TokenResponse> {
if user_from_token.merchant_id == request.merchant_id {
return Err(UserErrors::InvalidRoleOperationWithMessage(
"User switching to same merchant".to_string(),
)
.into());
}
let key_manager_state = &(&state).into();
let role_info = roles::RoleInfo::from_role_id_org_id_tenant_id(
&state,
&user_from_token.role_id,
&user_from_token.org_id,
user_from_token
.tenant_id
.as_ref()
.unwrap_or(&state.tenant.tenant_id),
)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to retrieve role information")?;
// Check if the role is internal and handle separately
let (org_id, merchant_id, profile_id, role_id) = if role_info.is_internal() {
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
key_manager_state,
&request.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
.await
.to_not_found_response(UserErrors::MerchantIdNotFound)?;
let merchant_account = state
.store
.find_merchant_account_by_merchant_id(
key_manager_state,
&request.merchant_id,
&merchant_key_store,
)
.await
.to_not_found_response(UserErrors::MerchantIdNotFound)?;
let profile_id = state
.store
.list_profile_by_merchant_id(
key_manager_state,
&merchant_key_store,
&request.merchant_id,
)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to list business profiles by merchant_id")?
.pop()
.ok_or(UserErrors::InternalServerError)
.attach_printable("No business profile found for the given merchant_id")?
.get_id()
.to_owned();
(
merchant_account.organization_id,
request.merchant_id,
profile_id,
user_from_token.role_id.clone(),
)
} else {
// Match based on the other entity types
match role_info.get_entity_type() {
EntityType::Tenant | EntityType::Organization => {
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
key_manager_state,
&request.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
.await
.to_not_found_response(UserErrors::MerchantIdNotFound)?;
let merchant_id = state
.store
.find_merchant_account_by_merchant_id(
key_manager_state,
&request.merchant_id,
&merchant_key_store,
)
.await
.change_context(UserErrors::MerchantIdNotFound)?
.organization_id
.eq(&user_from_token.org_id)
.then(|| request.merchant_id.clone())
.ok_or_else(|| {
UserErrors::InvalidRoleOperationWithMessage(
"No such merchant_id found for the user in the org".to_string(),
)
})?;
let profile_id = state
.store
.list_profile_by_merchant_id(
key_manager_state,
&merchant_key_store,
&merchant_id,
)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to list business profiles by merchant_id")?
.pop()
.ok_or(UserErrors::InternalServerError)
.attach_printable("No business profile found for the merchant_id")?
.get_id()
.to_owned();
(
user_from_token.org_id.clone(),
merchant_id,
profile_id,
user_from_token.role_id.clone(),
)
}
EntityType::Merchant | EntityType::Profile => {
let user_role = state
.global_store
.list_user_roles_by_user_id(ListUserRolesByUserIdPayload {
user_id: &user_from_token.user_id,
tenant_id: user_from_token
.tenant_id
.as_ref()
.unwrap_or(&state.tenant.tenant_id),
org_id: Some(&user_from_token.org_id),
merchant_id: Some(&request.merchant_id),
profile_id: None,
entity_id: None,
version: None,
status: Some(UserStatus::Active),
limit: Some(1),
})
.await
.change_context(UserErrors::InternalServerError)
.attach_printable(
"Failed to list user roles for the given user_id, org_id and merchant_id",
)?
.pop()
.ok_or(UserErrors::InvalidRoleOperationWithMessage(
"No user role associated with the requested merchant_id".to_string(),
))?;
let (merchant_id, profile_id) =
utils::user_role::get_single_merchant_id_and_profile_id(&state, &user_role)
.await?;
(
user_from_token.org_id,
merchant_id,
profile_id,
user_role.role_id,
)
}
}
};
let token = utils::user::generate_jwt_auth_token_with_attributes(
&state,
user_from_token.user_id,
merchant_id.clone(),
org_id.clone(),
role_id.clone(),
profile_id,
user_from_token.tenant_id.clone(),
)
.await?;
utils::user_role::set_role_info_in_cache_by_role_id_org_id(
&state,
&role_id,
&org_id,
user_from_token
.tenant_id
.as_ref()
.unwrap_or(&state.tenant.tenant_id),
)
.await;
let response = user_api::TokenResponse {
token: token.clone(),
token_type: common_enums::TokenPurpose::UserInfo,
};
auth::cookies::set_cookie_response(response, token)
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use std::{
collections::{HashMap, HashSet},
ops::Not,
};
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use error_stack::{report, ResultExt};
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
pub async fn list_user_roles_details(
state: SessionState,
user_from_token: auth::UserFromToken,
request: user_api::GetUserRoleDetailsRequest,
_req_state: ReqState,
) -> UserResponse<Vec<user_api::GetUserRoleDetailsResponseV2>> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
async fn handle_new_user_invitation(
state: &SessionState,
user_from_token: &auth::UserFromToken,
request: &user_api::InviteUserRequest,
role_info: roles::RoleInfo,
req_state: ReqState,
auth_id: &Option<String>,
) -> UserResult<InviteMultipleUserResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user.rs | crate: router
use api_models::{
payments::RedirectionResponse,
user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},
};
use common_enums::{EntityType, UserAuthType};
use common_utils::{type_name, types::keymanager::Identifier};
use diesel_models::user_role::UserRoleUpdate;
use diesel_models::{
enums::{TotpStatus, UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user as storage_user,
user_authentication_method::{UserAuthenticationMethodNew, UserAuthenticationMethodUpdate},
};
use router_env::logger;
use user_api::dashboard_metadata::SetMetaDataRequest;
use super::errors::{StorageErrorExt, UserErrors, UserResponse, UserResult};
use crate::services::email::types as email_types;
use crate::{
consts,
core::encryption::send_request_to_key_service_for_user,
db::{
domain::user_authentication_method::DEFAULT_USER_AUTH_METHOD,
user_role::ListUserRolesByUserIdPayload,
},
routes::{app::ReqState, SessionState},
services::{authentication as auth, authorization::roles, openidconnect, ApplicationResponse},
types::{domain, transformers::ForeignInto},
utils::{
self,
user::{theme as theme_utils, two_factor_auth as tfa_utils},
},
};
async fn handle_existing_user_invitation(
state: &SessionState,
user_from_token: &auth::UserFromToken,
request: &user_api::InviteUserRequest,
invitee_user_from_db: domain::UserFromStorage,
role_info: roles::RoleInfo,
auth_id: &Option<String>,
) -> UserResult<InviteMultipleUserResponse> {
{
EntityType::Tenant => {
return Err(UserErrors::InvalidRoleOperationWithMessage(
"Tenant roles are not allowed for this operation".to_string(),
)
.into());
}<|fim_suffix|>
<|fim_middle|>
EntityType::Profile => {
user_role
.add_entity(domain::ProfileLevel {
tenant_id: user_from_token
.tenant_id
.clone()
.unwrap_or(state.tenant.tenant_id.clone()),
org_id: user_from_token.org_id.clone(),
merchant_id: user_from_token.merchant_id.clone(),
profile_id: user_from_token.profile_id.clone(),
})
.insert_in_v2(state)
.await?
}
}
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user_role.rs | crate: router
use api_models::{
user as user_api,
user_role::{self as user_role_api, role as role_api},
};
use diesel_models::{
enums::{UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user_role::UserRoleUpdate,
};
use error_stack::{report, ResultExt};
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
db::user_role::{ListUserRolesByOrgIdPayload, ListUserRolesByUserIdPayload},
routes::{app::ReqState, SessionState},
services::{
authentication as auth,
authorization::{
info,
permission_groups::{ParentGroupExt, PermissionGroupExt},
roles,
},
ApplicationResponse,
},
types::domain,
utils,
};
pub async fn accept_invitations_pre_auth(
state: SessionState,
user_token: auth::UserFromSinglePurposeToken,
req: user_role_api::AcceptInvitationsPreAuthRequest,
) -> UserResponse<user_api::TokenResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user_role.rs | crate: router
use api_models::{
user as user_api,
user_role::{self as user_role_api, role as role_api},
};
use diesel_models::{
enums::{UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user_role::UserRoleUpdate,
};
use error_stack::{report, ResultExt};
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
db::user_role::{ListUserRolesByOrgIdPayload, ListUserRolesByUserIdPayload},
routes::{app::ReqState, SessionState},
services::{
authentication as auth,
authorization::{
info,
permission_groups::{ParentGroupExt, PermissionGroupExt},
roles,
},
ApplicationResponse,
},
types::domain,
utils,
};
pub async fn accept_invitations_v2(
state: SessionState,
user_from_token: auth::UserFromToken,
req: user_role_api::AcceptInvitationsV2Request,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user_role.rs | crate: router
use std::collections::{HashMap, HashSet};
use api_models::{
user as user_api,
user_role::{self as user_role_api, role as role_api},
};
use diesel_models::{
enums::{UserRoleVersion, UserStatus},
organization::OrganizationBridge,
user_role::UserRoleUpdate,
};
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
db::user_role::{ListUserRolesByOrgIdPayload, ListUserRolesByUserIdPayload},
routes::{app::ReqState, SessionState},
services::{
authentication as auth,
authorization::{
info,
permission_groups::{ParentGroupExt, PermissionGroupExt},
roles,
},
ApplicationResponse,
},
types::domain,
utils,
};
use common_enums::{EntityType, ParentGroup, PermissionGroup};
pub async fn get_parent_group_info(
state: SessionState,
user_from_token: auth::UserFromToken,
) -> UserResponse<Vec<role_api::ParentGroupInfo>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.