forked from Roflin/gamenight
Fixes leave on the server and reworked login flow.
This commit is contained in:
@@ -105,14 +105,22 @@ pub async fn login(pool: web::Data<DbPool>, login_data: web::Json<Login>) -> Res
|
||||
let response = Token{ jwt_token: Some(token) };
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
.body(serde_json::to_string(&response)?)
|
||||
)
|
||||
.body(serde_json::to_string(&response)?))
|
||||
}
|
||||
else {
|
||||
Err(ApiError{status: 401, message: "User doesn't exist or password doesn't match".to_string()})
|
||||
}
|
||||
}
|
||||
|
||||
#[post("/token")]
|
||||
pub async fn refresh(user: AuthUser) -> Result<impl Responder, ApiError> {
|
||||
let new_token = get_token(&user.0)?;
|
||||
let response = Token{ jwt_token: Some(new_token) };
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
.body(serde_json::to_string(&response)?))
|
||||
}
|
||||
|
||||
#[post("/user")]
|
||||
pub async fn register(pool: web::Data<DbPool>, register_data: web::Json<Registration>) -> Result<impl Responder, ApiError> {
|
||||
web::block(move || -> Result<(), ApiError> {
|
||||
|
||||
Reference in New Issue
Block a user