fxa_client/
account.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5//! # Account Management URLs
6//!
7//! Signed-in applications should not attempt to perform an account-level management
8//! (such as changing profile data or managing devices) using native UI. Instead, they
9//! should offer the user the opportunity to visit their account management pages on the
10//! web.
11//!
12//! The methods in this section provide URLs at which the user can perform various
13//! account-management activities.
14
15use crate::{ApiResult, Error, FirefoxAccount, FxaServer};
16use error_support::handle_error;
17
18#[uniffi::export]
19impl FirefoxAccount {
20    /// Check if an account was created from a config
21    #[handle_error(Error)]
22    pub fn matches_server(&self, server: &FxaServer) -> ApiResult<bool> {
23        self.internal.lock().matches_server(server)
24    }
25
26    /// Get the token server URL
27    ///
28    /// The token server URL can be used to get the URL and access token for the user's sync data.
29    #[handle_error(Error)]
30    pub fn get_token_server_endpoint_url(&self) -> ApiResult<String> {
31        self.internal.lock().get_token_server_endpoint_url()
32    }
33
34    /// Get a URL which shows a "successfully connected!" message.
35    ///
36    /// **💾 This method alters the persisted account state.**
37    ///
38    /// Applications can use this method after a successful signin, to redirect the
39    /// user to a success message displayed in web content rather than having to
40    /// implement their own native success UI.
41    #[handle_error(Error)]
42    pub fn get_connection_success_url(&self) -> ApiResult<String> {
43        self.internal.lock().get_connection_success_url()
44    }
45
46    /// Get a URL at which the user can manage their account and profile data.
47    ///
48    /// **💾 This method alters the persisted account state.**
49    ///
50    /// Applications should link the user out to this URL from an appropriate place
51    /// in their signed-in settings UI.
52    ///
53    /// # Arguments
54    ///
55    ///   - `entrypoint` - metrics identifier for UX entrypoint.
56    ///       - This parameter is used for metrics purposes, to identify the
57    ///         UX entrypoint from which the user followed the link.
58    #[handle_error(Error)]
59    pub fn get_manage_account_url(&self, entrypoint: &str) -> ApiResult<String> {
60        self.internal.lock().get_manage_account_url(entrypoint)
61    }
62
63    /// Get a URL at which the user can manage the devices connected to their account.
64    ///
65    /// **💾 This method alters the persisted account state.**
66    ///
67    /// Applications should link the user out to this URL from an appropriate place
68    /// in their signed-in settings UI. For example, "Manage your devices..." may be
69    /// a useful link to place somewhere near the device list in the send-tab UI.
70    ///
71    /// # Arguments
72    ///
73    ///   - `entrypoint` - metrics identifier for UX entrypoint.
74    ///       - This parameter is used for metrics purposes, to identify the
75    ///         UX entrypoint from which the user followed the link.
76    #[handle_error(Error)]
77    pub fn get_manage_devices_url(&self, entrypoint: &str) -> ApiResult<String> {
78        self.internal.lock().get_manage_devices_url(entrypoint)
79    }
80}