mirror of
https://github.com/agersant/polaris
synced 2024-12-04 18:49:10 +00:00
Run server on expected port (5050 or custom)
This commit is contained in:
parent
ed2ae20951
commit
cba28e8e2c
3 changed files with 8 additions and 4 deletions
|
@ -30,6 +30,7 @@ error_chain! {
|
|||
Time(std::time::SystemTimeError);
|
||||
Toml(toml::de::Error);
|
||||
Regex(regex::Error);
|
||||
RocketConfig(rocket::config::ConfigError);
|
||||
Scrobbler(rustfm_scrobble::ScrobblerError);
|
||||
Vorbis(lewton::VorbisError);
|
||||
}
|
||||
|
|
|
@ -235,10 +235,13 @@ fn run() -> Result<()> {
|
|||
.parse()
|
||||
.or(Err("invalid port number"))?;
|
||||
|
||||
// TODO Use port number
|
||||
let config = rocket::Config::build(rocket::config::Environment::Production)
|
||||
.port(port)
|
||||
.finalize()?;
|
||||
|
||||
let db_server = db.clone();
|
||||
std::thread::spawn(move || {
|
||||
rocket::ignite()
|
||||
rocket::custom(config)
|
||||
.manage(db_server)
|
||||
.manage(command_sender)
|
||||
.mount(&static_url, StaticFiles::from(web_dir_path))
|
||||
|
|
|
@ -82,11 +82,11 @@ impl<'a, 'r> FromRequest<'a, 'r> for Auth {
|
|||
if let Ok(Basic {
|
||||
username,
|
||||
password: Some(password),
|
||||
}) = Basic::from_str(auth_header_string.trim_start_matches("Basic ")) // Sadness
|
||||
}) = Basic::from_str(auth_header_string.trim_start_matches("Basic "))
|
||||
{
|
||||
let db = match request.guard::<State<Arc<DB>>>() {
|
||||
Outcome::Success(d) => d,
|
||||
_ => return Outcome::Failure((Status::InternalServerError, ()))
|
||||
_ => return Outcome::Failure((Status::InternalServerError, ())),
|
||||
};
|
||||
if user::auth(db.deref().deref(), &username, &password).unwrap_or(false) {
|
||||
cookies.add_private(get_auth_cookie(&username));
|
||||
|
|
Loading…
Reference in a new issue