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};
16use error_support::handle_error;
17
18impl FirefoxAccount {
19 /// Get the token server URL
20 ///
21 /// The token server URL can be used to get the URL and access token for the user's sync data.
22 ///
23 /// **💾 This method alters the persisted account state.**
24 #[handle_error(Error)]
25 pub fn get_token_server_endpoint_url(&self) -> ApiResult<String> {
26 self.internal.lock().get_token_server_endpoint_url()
27 }
28
29 /// Get a URL which shows a "successfully connected!" message.
30 ///
31 /// **💾 This method alters the persisted account state.**
32 ///
33 /// Applications can use this method after a successful signin, to redirect the
34 /// user to a success message displayed in web content rather than having to
35 /// implement their own native success UI.
36 #[handle_error(Error)]
37 pub fn get_connection_success_url(&self) -> ApiResult<String> {
38 self.internal.lock().get_connection_success_url()
39 }
40
41 /// Get a URL at which the user can manage their account and profile data.
42 ///
43 /// **💾 This method alters the persisted account state.**
44 ///
45 /// Applications should link the user out to this URL from an appropriate place
46 /// in their signed-in settings UI.
47 ///
48 /// # Arguments
49 ///
50 /// - `entrypoint` - metrics identifier for UX entrypoint.
51 /// - This parameter is used for metrics purposes, to identify the
52 /// UX entrypoint from which the user followed the link.
53 #[handle_error(Error)]
54 pub fn get_manage_account_url(&self, entrypoint: &str) -> ApiResult<String> {
55 self.internal.lock().get_manage_account_url(entrypoint)
56 }
57
58 /// Get a URL at which the user can manage the devices connected to their account.
59 ///
60 /// **💾 This method alters the persisted account state.**
61 ///
62 /// Applications should link the user out to this URL from an appropriate place
63 /// in their signed-in settings UI. For example, "Manage your devices..." may be
64 /// a useful link to place somewhere near the device list in the send-tab UI.
65 ///
66 /// # Arguments
67 ///
68 /// - `entrypoint` - metrics identifier for UX entrypoint.
69 /// - This parameter is used for metrics purposes, to identify the
70 /// UX entrypoint from which the user followed the link.
71 #[handle_error(Error)]
72 pub fn get_manage_devices_url(&self, entrypoint: &str) -> ApiResult<String> {
73 self.internal.lock().get_manage_devices_url(entrypoint)
74 }
75}