fmt: updated the formatting #43
8 changed files with 1370 additions and 1358 deletions
|
@ -1,6 +1,9 @@
|
|||
max_width = 1000
|
||||
max_width = 150
|
||||
single_line_if_else_max_width = 100
|
||||
chain_width = 100
|
||||
fn_params_layout = "Compressed"
|
||||
#control_brace_style = "ClosingNextLine"
|
||||
#brace_style = "PreferSameLine"
|
||||
struct_lit_width = 0
|
||||
tab_spaces = 2
|
||||
use_small_heuristics = "Max"
|
|
@ -33,7 +33,12 @@ async fn update_ldap(config: &Config, db: &Pool<Sqlite>) {
|
|||
ldap.simple_bind(&config.ldap_admin, &config.ldap_admin_pw).unwrap().success().unwrap();
|
||||
|
||||
// use this to pre load a large chunk of data
|
||||
if let Ok(x) = ldap.search("ou=users,dc=skynet,dc=ie", Scope::OneLevel, "(objectClass=*)", vec!["uid", "uidNumber", "skDiscord", "skMemberOf", "mail", "skID", "userPassword"]) {
|
||||
if let Ok(x) = ldap.search(
|
||||
"ou=users,dc=skynet,dc=ie",
|
||||
Scope::OneLevel,
|
||||
"(objectClass=*)",
|
||||
vec!["uid", "uidNumber", "skDiscord", "skMemberOf", "mail", "skID", "userPassword"],
|
||||
) {
|
||||
if let Ok((rs, _res)) = x.success() {
|
||||
for entry in rs {
|
||||
let tmp = SearchEntry::construct(entry);
|
||||
|
@ -64,7 +69,10 @@ async fn update_ldap(config: &Config, db: &Pool<Sqlite>) {
|
|||
if tmp.attrs.contains_key("skID") && !tmp.attrs["skID"].is_empty() {
|
||||
tmp_account.student_id = tmp.attrs["skID"][0].clone();
|
||||
}
|
||||
if tmp.attrs.contains_key("skMemberOf") && !tmp.attrs["skMemberOf"].is_empty() && tmp.attrs["skMemberOf"].contains(&String::from("cn=skynet-users-linux,ou=groups,dc=skynet,dc=ie")) {
|
||||
if tmp.attrs.contains_key("skMemberOf")
|
||||
&& !tmp.attrs["skMemberOf"].is_empty()
|
||||
&& tmp.attrs["skMemberOf"].contains(&String::from("cn=skynet-users-linux,ou=groups,dc=skynet,dc=ie"))
|
||||
{
|
||||
tmp_account.enabled = true;
|
||||
}
|
||||
if tmp.attrs.contains_key("userPassword") && !tmp.attrs["userPassword"].is_empty() {
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::{get_now_iso, random_string, AccountWolves, Accounts, AccountsNew, Co
|
|||
use ldap3::{exop::PasswordModify, LdapConn, Scope};
|
||||
use lettre::{
|
||||
message::{header, MultiPart, SinglePart},
|
||||
transport::smtp::authentication::Credentials,
|
||||
transport::smtp::{self, authentication::Credentials},
|
||||
Message, SmtpTransport, Transport,
|
||||
};
|
||||
use maud::html;
|
||||
|
@ -106,7 +106,7 @@ pub mod email {
|
|||
}
|
||||
|
||||
// using https://github.com/lettre/lettre/blob/57886c367d69b4d66300b322c94bd910b1eca364/examples/maud_html.rs
|
||||
fn send_mail(config: &Config, record: &AccountWolves, auth: &str) -> Result<lettre::transport::smtp::response::Response, lettre::transport::smtp::Error> {
|
||||
fn send_mail(config: &Config, record: &AccountWolves, auth: &str) -> Result<smtp::response::Response, smtp::Error> {
|
||||
let recipient = &record.name_first;
|
||||
let mail = &record.email;
|
||||
let url_base = "https://account.skynet.ie";
|
||||
|
@ -369,7 +369,8 @@ pub mod account {
|
|||
let uid_number = get_max_uid_number(db).await;
|
||||
|
||||
// create user
|
||||
ldap.add(
|
||||
ldap
|
||||
.add(
|
||||
&dn,
|
||||
vec![
|
||||
("objectClass", HashSet::from(["top", "person", "posixaccount", "ldapPublicKey", "inetOrgPerson", "skPerson"])),
|
||||
|
|
Loading…
Reference in a new issue