Routes for auth handling
Also db and structs are now identical
This commit is contained in:
@@ -30,8 +30,8 @@ pub struct TicketResponse {
|
|||||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub id: i16,
|
pub id: i16,
|
||||||
pub first_name: String,
|
|
||||||
pub last_name: String,
|
pub last_name: String,
|
||||||
|
pub first_name: String,
|
||||||
pub is_admin: bool,
|
pub is_admin: bool,
|
||||||
pub pwd: String,
|
pub pwd: String,
|
||||||
}
|
}
|
||||||
@@ -67,8 +67,8 @@ pub struct LoginScheme {
|
|||||||
#[derive(Deserialize, Serialize, Debug, sqlx::FromRow)]
|
#[derive(Deserialize, Serialize, Debug, sqlx::FromRow)]
|
||||||
pub struct LoginModel {
|
pub struct LoginModel {
|
||||||
pub id: i16,
|
pub id: i16,
|
||||||
pub first_name: String,
|
|
||||||
pub last_name: String,
|
pub last_name: String,
|
||||||
|
pub first_name: String,
|
||||||
pub is_admin: bool,
|
pub is_admin: bool,
|
||||||
pub pwd: String,
|
pub pwd: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ use axum::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
AppState,
|
AppState,
|
||||||
handlers::ticket::{create_ticket, delete_ticket, edit_ticket, get_ticket_by_id, get_tickets},
|
handlers::{
|
||||||
|
auth::{create_user, login, logout},
|
||||||
|
ticket::{create_ticket, delete_ticket, edit_ticket, get_ticket_by_id, get_tickets},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn create_router(state: Arc<AppState>) -> Router {
|
pub fn create_router(state: Arc<AppState>) -> Router {
|
||||||
@@ -20,5 +23,8 @@ pub fn create_router(state: Arc<AppState>) -> Router {
|
|||||||
.delete(delete_ticket)
|
.delete(delete_ticket)
|
||||||
.patch(edit_ticket),
|
.patch(edit_ticket),
|
||||||
)
|
)
|
||||||
|
.route("/api/register", post(create_user))
|
||||||
|
.route("/api/login", post(login))
|
||||||
|
.route("/api/logout", get(logout))
|
||||||
.with_state(state)
|
.with_state(state)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user