update dockerfile, pipeline, and tweak main

This commit is contained in:
Mitchell Marino
2023-04-05 14:55:44 -05:00
parent 2856b1bbd8
commit c786b36cd3
3 changed files with 9 additions and 2 deletions
+1
View File
@@ -1,5 +1,6 @@
FROM rust:latest as build
ENV DATABASE_URL="postgres://school_app_api_user:school_app_api_pass@mdev.local/school_app_api"
WORKDIR /usr/src/school_app_api
COPY . .
+5 -1
View File
@@ -28,7 +28,6 @@ jobs:
- name: test
plan:
- get: repo
- get: rust
trigger: true
- task: test
config:
@@ -38,6 +37,7 @@ jobs:
source:
repository: rust
params:
DATABASE_URL: "postgres://school_app_api_user:school_app_api_pass@mdev.local/school_app_api"
CARGO_HOME: "./.cargo-config/"
RUSTUP_HOME: "./.rustup-config"
@@ -65,6 +65,7 @@ jobs:
source:
repository: rust
params:
DATABASE_URL: "postgres://school_app_api_user:school_app_api_pass@mdev.local/school_app_api"
CARGO_HOME: "./.cargo-config/"
RUSTUP_HOME: "./.rustup-config"
@@ -93,6 +94,7 @@ jobs:
source:
repository: rust
params:
DATABASE_URL: "postgres://school_app_api_user:school_app_api_pass@mdev.local/school_app_api"
CARGO_HOME: "./.cargo-config/"
RUSTUP_HOME: "./.rustup-config"
@@ -122,6 +124,7 @@ jobs:
source:
repository: rust
params:
DATABASE_URL: "postgres://school_app_api_user:school_app_api_pass@mdev.local/school_app_api"
CARGO_HOME: "./.cargo-config/"
RUSTUP_HOME: "./.rustup-config"
@@ -156,6 +159,7 @@ jobs:
source:
repository: rust
params:
DATABASE_URL: "postgres://school_app_api_user:school_app_api_pass@mdev.local/school_app_api"
CARGO_HOME: "./.cargo-config/"
RUSTUP_HOME: "./.rustup-config"
+3 -1
View File
@@ -14,6 +14,7 @@ use std::net::SocketAddr;
#[derive(Clone, Serialize, Deserialize, Debug, Hash)]
struct Claims {
id: i32,
username: String,
}
@@ -121,7 +122,7 @@ async fn signin(
let result = sqlx::query!(
r#"
SELECT username
SELECT id, username
FROM users
WHERE username = $1 AND password = $2
"#,
@@ -134,6 +135,7 @@ async fn signin(
match result {
Ok(Some(user)) => {
let claims = Claims {
id: user.id,
username: user.username,
};
let token = match jsonwebtoken::encode(&Header::default(), &claims, &app_state.jwt_key)