Compare commits

...

2 commits

Author SHA1 Message Date
79dc4c780a Update Rust crate openssl to v0.10.79
All checks were successful
Build and Test / account (push) Successful in 5m55s
2026-05-04 19:30:27 +00:00
ac7cb0ddee Add token type to GraphQL requests
All checks were successful
Build and Test / account (push) Successful in 7m45s
2026-05-04 21:27:32 +02:00
2 changed files with 37 additions and 8 deletions

21
Cargo.lock generated
View file

@ -2516,15 +2516,14 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "openssl"
version = "0.10.78"
version = "0.10.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f38c4372413cdaaf3cc79dd92d29d7d9f5ab09b51b10dded508fb90bb70b9222"
checksum = "bf0b434746ee2832f4f0baf10137e1cabb18cbe6912c69e2e33263c45250f542"
dependencies = [
"bitflags",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
@ -2553,13 +2552,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
[[package]]
name = "openssl-sys"
version = "0.9.114"
name = "openssl-src"
version = "300.6.0+3.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13ce1245cd07fcc4cfdb438f7507b0c7e4f3849a69fd84d52374c66d83741bb6"
checksum = "a8e8cbfd3a4a8c8f089147fd7aaa33cf8c7450c4d09f8f80698a0cf093abeff4"
dependencies = [
"cc",
]
[[package]]
name = "openssl-sys"
version = "0.9.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "158fe5b292746440aa6e7a7e690e55aeb72d41505e2804c23c6973ad0e9c9781"
dependencies = [
"cc",
"libc",
"openssl-src",
"pkg-config",
"vcpkg",
]

View file

@ -48,7 +48,8 @@ impl juniper::Context for Context {}
struct TokenInfo {
pid: i32,
expire_date: NaiveDateTime,
title_id: Option<String>
title_id: Option<String>,
token_type: i32
}
#[derive(GraphQLObject)]
@ -60,6 +61,16 @@ struct UserInfo {
mii_data: String,
}
#[derive(GraphQLObject)]
#[graphql(description = "User information from a token")]
struct TokenUserInfo {
username: String,
account_level: i32,
nex_password: String,
mii_data: String,
token_type: i32,
}
#[derive(GraphQLObject)]
#[graphql(description = "User information from a username")]
pub struct UserInfoWithPId {
@ -96,13 +107,14 @@ impl Query {
pid: data.pid,
expire_date: token_info.expires,
title_id: token_info.title_id,
token_type: token_info.token_type,
})
}
async fn user_from_token(
token_data: String,
context: &Context,
) -> Option<UserInfo> {
) -> Option<TokenUserInfo> {
let data = match TokenData::decode(&token_data) {
Some(data) => data,
None => {
@ -111,6 +123,13 @@ impl Query {
}
};
let token_info =
sqlx::query!(
"select * from tokens where pid = $1 and token_id = $2 and random = $3",
data.pid, data.token_id, data.random
).
fetch_one(&context.pool).await.ok()?;
let user = match sqlx::query!(
"SELECT username, account_level, nex_password, mii_data FROM users WHERE pid = $1",
data.pid
@ -127,11 +146,12 @@ impl Query {
let nex_password = user.nex_password;
Some(UserInfo {
Some(TokenUserInfo {
username: user.username,
account_level: user.account_level,
nex_password,
mii_data: user.mii_data.replace('\n', "").replace('\r', ""),
token_type: token_info.token_type
})
}