fmt: clippy and fmt
This commit is contained in:
parent
2b96d498a7
commit
e21af089d1
2 changed files with 62 additions and 99 deletions
26
src/lib.rs
26
src/lib.rs
|
@ -40,7 +40,7 @@ pub struct Accounts {
|
|||
mail: String,
|
||||
student_id: String,
|
||||
enabled: bool,
|
||||
secure: bool,
|
||||
secure: bool,
|
||||
}
|
||||
|
||||
pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
|
||||
|
@ -74,12 +74,12 @@ pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
|
|||
name_surname integer not null
|
||||
)",
|
||||
)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS index_auth_code ON accounts_new (auth_code)")
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
// this is for active use
|
||||
sqlx::query(
|
||||
|
@ -96,9 +96,7 @@ pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
|
|||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS index_uid_number ON accounts (uid)")
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS index_uid_number ON accounts (uid)").execute(&pool).await?;
|
||||
|
||||
update_accounts(&pool, config).await;
|
||||
|
||||
|
@ -190,12 +188,7 @@ async fn update_accounts(pool: &Pool<Sqlite>, config: &Config) {
|
|||
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", "skSecure"]
|
||||
) {
|
||||
if let Ok(x) = ldap.search("ou=users,dc=skynet,dc=ie", Scope::OneLevel, "(objectClass=*)", vec!["uid", "uidNumber", "skDiscord", "skMemberOf", "mail", "skID", "skSecure"]) {
|
||||
if let Ok((rs, _res)) = x.success() {
|
||||
for entry in rs {
|
||||
let tmp = SearchEntry::construct(entry);
|
||||
|
@ -226,10 +219,7 @@ async fn update_accounts(pool: &Pool<Sqlite>, config: &Config) {
|
|||
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("skSecure") && !tmp.attrs["skSecure"].is_empty() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue