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