1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use crateResult;
pub use ;
pub use ;
pub use PopulateUsersReturn;
/*
// TODO need to support this stuff again
/// Initiates the password dialog for the current user for all the given datasets.
/// If None, the current dataset is used.
pub fn set_passwords(datasets: Option<Vec<&str>>) -> Result<()> {
if let Some(datasets) = datasets {
let mut err_str = "".to_string();
for ds in datasets {
match crate::with_current_user(|u| u._password_dialog(&ds.to_string(), None)) {
Ok(_) => {}
Err(e) => {
err_str.push_str(&format!("{}\n", e.msg));
}
}
}
if err_str != "" {
bail!("{}", err_str)
} else {
Ok(())
}
} else {
crate::with_current_user(|u| u._password_dialog(&u.top_datakey()?, None))?;
Ok(())
}
}
pub fn set_all_passwords() -> Result<()> {
let users = crate::users();
let u = users.current_user()?;
let datasets = u.datasets().keys();
set_passwords(Some(datasets.map(|s| s.as_str()).collect()))
}
pub fn clear_passwords(datasets: Option<Vec<&str>>) -> Result<()> {
if let Some(datasets) = datasets {
let mut err_str = "".to_string();
for ds in datasets {
log_trace!("Clearing password for {}", ds);
match crate::with_current_user(|u| u.clear_cached_password(Some(&ds))) {
Ok(_) => {}
Err(e) => {
err_str.push_str(&format!("{}\n", e.msg));
}
}
}
if err_str != "" {
bail!("{}", err_str)
} else {
Ok(())
}
} else {
log_trace!("Clearing password for current dataset");
crate::with_current_user(|u| u.clear_cached_password(None))?;
Ok(())
}
}
pub fn clear_all_passwords() -> Result<()> {
log_trace!("Clearing all cached passwords for current user");
crate::with_current_user(|u| u.clear_cached_passwords())
}
*/