Move username and password to config file
This commit is contained in:
parent
654bc5c7f8
commit
8d75aaa4f7
6 changed files with 46 additions and 27 deletions
src/lemmy
|
@ -1,6 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::env::VarError;
|
||||
use lemmy_api_common::community::{ListCommunities, ListCommunitiesResponse};
|
||||
use lemmy_api_common::lemmy_db_views::structs::PostView;
|
||||
use lemmy_api_common::person::{Login, LoginResponse};
|
||||
|
@ -9,6 +7,7 @@ use lemmy_api_common::sensitive::Sensitive;
|
|||
use lemmy_db_schema::newtypes::{CommunityId, PostId};
|
||||
use lemmy_db_schema::{ListingType, PostFeatureType};
|
||||
use reqwest::StatusCode;
|
||||
use crate::config::Config;
|
||||
use crate::HTTP_CLIENT;
|
||||
|
||||
pub(crate) struct Credentials {
|
||||
|
@ -25,13 +24,11 @@ impl Credentials {
|
|||
Sensitive::new(self.password.clone())
|
||||
}
|
||||
|
||||
pub(crate) fn set_credentials() -> Result<Self, VarError> {
|
||||
let username = env::var("LEMMY_USERNAME")?;
|
||||
let password = env::var("LEMMY_PASSWORD")?;
|
||||
Ok(Credentials {
|
||||
username,
|
||||
password,
|
||||
})
|
||||
pub(crate) fn set_credentials(config: &Config) -> Self {
|
||||
Self {
|
||||
username: config.username.clone(),
|
||||
password: config.password.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue