Compare commits
1 commit
main
...
renovate/q
| Author | SHA1 | Date | |
|---|---|---|---|
| 77a29f3186 |
2 changed files with 5 additions and 25 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -2810,9 +2810,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-xml"
|
name = "quick-xml"
|
||||||
version = "0.39.2"
|
version = "0.39.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "958f21e8e7ceb5a1aa7fa87fab28e7c75976e0bfe7e23ff069e0a260f894067d"
|
checksum = "721da970c312655cde9b4ffe0547f20a8494866a4af5ff51f18b7c633d0c870b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,7 @@ impl juniper::Context for Context {}
|
||||||
struct TokenInfo {
|
struct TokenInfo {
|
||||||
pid: i32,
|
pid: i32,
|
||||||
expire_date: NaiveDateTime,
|
expire_date: NaiveDateTime,
|
||||||
title_id: Option<String>,
|
title_id: Option<String>
|
||||||
token_type: i32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(GraphQLObject)]
|
#[derive(GraphQLObject)]
|
||||||
|
|
@ -61,16 +60,6 @@ struct UserInfo {
|
||||||
mii_data: String,
|
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)]
|
#[derive(GraphQLObject)]
|
||||||
#[graphql(description = "User information from a username")]
|
#[graphql(description = "User information from a username")]
|
||||||
pub struct UserInfoWithPId {
|
pub struct UserInfoWithPId {
|
||||||
|
|
@ -107,14 +96,13 @@ impl Query {
|
||||||
pid: data.pid,
|
pid: data.pid,
|
||||||
expire_date: token_info.expires,
|
expire_date: token_info.expires,
|
||||||
title_id: token_info.title_id,
|
title_id: token_info.title_id,
|
||||||
token_type: token_info.token_type,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn user_from_token(
|
async fn user_from_token(
|
||||||
token_data: String,
|
token_data: String,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
) -> Option<TokenUserInfo> {
|
) -> Option<UserInfo> {
|
||||||
let data = match TokenData::decode(&token_data) {
|
let data = match TokenData::decode(&token_data) {
|
||||||
Some(data) => data,
|
Some(data) => data,
|
||||||
None => {
|
None => {
|
||||||
|
|
@ -123,13 +111,6 @@ 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!(
|
let user = match sqlx::query!(
|
||||||
"SELECT username, account_level, nex_password, mii_data FROM users WHERE pid = $1",
|
"SELECT username, account_level, nex_password, mii_data FROM users WHERE pid = $1",
|
||||||
data.pid
|
data.pid
|
||||||
|
|
@ -146,12 +127,11 @@ impl Query {
|
||||||
|
|
||||||
let nex_password = user.nex_password;
|
let nex_password = user.nex_password;
|
||||||
|
|
||||||
Some(TokenUserInfo {
|
Some(UserInfo {
|
||||||
username: user.username,
|
username: user.username,
|
||||||
account_level: user.account_level,
|
account_level: user.account_level,
|
||||||
nex_password,
|
nex_password,
|
||||||
mii_data: user.mii_data.replace('\n', "").replace('\r', ""),
|
mii_data: user.mii_data.replace('\n', "").replace('\r', ""),
|
||||||
token_type: token_info.token_type
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue