You've already forked AstralRinth
forked from didirus/AstralRinth
feat: add support for multiple account types in database
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "\n SELECT\n uuid, active, username, access_token, refresh_token, expires\n FROM minecraft_users\n WHERE active = TRUE\n ",
|
||||
"query": "\n SELECT\n uuid, active, username, access_token, refresh_token, expires, account_type\n FROM minecraft_users\n WHERE active = TRUE\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -32,6 +32,11 @@
|
||||
"name": "expires",
|
||||
"ordinal": 5,
|
||||
"type_info": "Integer"
|
||||
},
|
||||
{
|
||||
"name": "account_type",
|
||||
"ordinal": 6,
|
||||
"type_info": "Text"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -43,8 +48,9 @@
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "bf7d47350092d87c478009adaab131168e87bb37aa65c2156ad2cb6198426d8c"
|
||||
"hash": "57214178fb3a0ccd8f67457e9732a706cbc4a4f5190c9320d1ad6111b9711d63"
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "\n SELECT\n uuid, active, username, access_token, refresh_token, expires\n FROM minecraft_users\n ",
|
||||
"query": "\n SELECT\n uuid, active, username, access_token, refresh_token, expires, account_type\n FROM minecraft_users\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -32,6 +32,11 @@
|
||||
"name": "expires",
|
||||
"ordinal": 5,
|
||||
"type_info": "Integer"
|
||||
},
|
||||
{
|
||||
"name": "account_type",
|
||||
"ordinal": 6,
|
||||
"type_info": "Text"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -43,8 +48,9 @@
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "727e3e1bc8625bbcb833920059bb8cea926ac6c65d613904eff1d740df30acda"
|
||||
"hash": "5c803f3d90c147210e8e7a7a6d7234d3801bc38c23e1e02fbd8fa08ae51e8f08"
|
||||
}
|
||||
12
packages/app-lib/.sqlx/query-8f7d4406ddae4a158eabb20fc6a8ffb21c4e22c7ff33459df5049ee441fa0467.json
generated
Normal file
12
packages/app-lib/.sqlx/query-8f7d4406ddae4a158eabb20fc6a8ffb21c4e22c7ff33459df5049ee441fa0467.json
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "\n INSERT INTO minecraft_users (uuid, active, username, access_token, refresh_token, expires, account_type)\n VALUES ($1, $2, $3, $4, $5, $6, $7)\n ON CONFLICT (uuid) DO UPDATE SET\n active = $2,\n username = $3,\n access_token = $4,\n refresh_token = $5,\n expires = $6,\n account_type = $7\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 7
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "8f7d4406ddae4a158eabb20fc6a8ffb21c4e22c7ff33459df5049ee441fa0467"
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "\n INSERT INTO minecraft_users (uuid, active, username, access_token, refresh_token, expires)\n VALUES ($1, $2, $3, $4, $5, $6)\n ON CONFLICT (uuid) DO UPDATE SET\n active = $2,\n username = $3,\n access_token = $4,\n refresh_token = $5,\n expires = $6\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 6
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "d719cf2f6f87c5ea7ea6ace2d6a1828ee58a724f06a91633b8a40b4e04d0b9a0"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [AR] - SQL Migration
|
||||
ALTER TABLE minecraft_users ADD COLUMN account_type varchar(32) NOT NULL DEFAULT 'unknown';
|
||||
|
||||
UPDATE minecraft_users SET account_type = 'microsoft' WHERE access_token != 'null';
|
||||
UPDATE minecraft_users SET account_type = 'pirate' WHERE access_token == 'null';
|
||||
@@ -131,6 +131,7 @@ where
|
||||
expires: legacy_credentials.expires,
|
||||
active: minecraft_auth.default_user == Some(uuid)
|
||||
|| minecraft_users_len == 1,
|
||||
account_type: legacy_credentials.account_type,
|
||||
}
|
||||
.upsert(exec)
|
||||
.await?;
|
||||
@@ -518,6 +519,7 @@ struct LegacyCredentials {
|
||||
pub access_token: String,
|
||||
pub refresh_token: String,
|
||||
pub expires: DateTime<Utc>,
|
||||
pub account_type: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
|
||||
@@ -191,6 +191,7 @@ pub async fn login_finish(
|
||||
expires: oauth_token.date
|
||||
+ Duration::seconds(oauth_token.value.expires_in as i64),
|
||||
active: true,
|
||||
account_type: AccountType::Microsoft.as_lowercase_str(),
|
||||
};
|
||||
|
||||
// During login, we need to fetch the online profile at least once to get the
|
||||
@@ -229,6 +230,7 @@ pub async fn offline_auth(
|
||||
refresh_token: refresh_token,
|
||||
expires: Utc::now() + Duration::days(365 * 99),
|
||||
active: true,
|
||||
account_type: AccountType::Pirate.as_lowercase_str(),
|
||||
};
|
||||
|
||||
credentials.offline_profile = MinecraftProfile {
|
||||
@@ -242,6 +244,30 @@ pub async fn offline_auth(
|
||||
Ok(credentials)
|
||||
}
|
||||
|
||||
/// [AR] • Feature
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub enum AccountType {
|
||||
Unknown,
|
||||
Microsoft,
|
||||
Pirate,
|
||||
ElyBy,
|
||||
}
|
||||
|
||||
impl AccountType {
|
||||
fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
AccountType::Unknown => "Unknown",
|
||||
AccountType::Microsoft => "Microsoft",
|
||||
AccountType::Pirate => "Pirate",
|
||||
AccountType::ElyBy => "ElyBy",
|
||||
}
|
||||
}
|
||||
|
||||
fn as_lowercase_str(&self) -> String {
|
||||
self.as_str().to_lowercase()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Credentials {
|
||||
/// The offline profile of the user these credentials are for.
|
||||
@@ -255,6 +281,7 @@ pub struct Credentials {
|
||||
pub refresh_token: String,
|
||||
pub expires: DateTime<Utc>,
|
||||
pub active: bool,
|
||||
pub account_type: String,
|
||||
}
|
||||
|
||||
/// An entry in the player profile cache, keyed by player UUID.
|
||||
@@ -480,7 +507,7 @@ impl Credentials {
|
||||
let res = sqlx::query!(
|
||||
"
|
||||
SELECT
|
||||
uuid, active, username, access_token, refresh_token, expires
|
||||
uuid, active, username, access_token, refresh_token, expires, account_type
|
||||
FROM minecraft_users
|
||||
WHERE active = TRUE
|
||||
"
|
||||
@@ -503,6 +530,7 @@ impl Credentials {
|
||||
.single()
|
||||
.unwrap_or_else(Utc::now),
|
||||
active: x.active == 1,
|
||||
account_type: x.account_type,
|
||||
};
|
||||
credentials.refresh(exec).await.ok();
|
||||
Some(credentials)
|
||||
@@ -517,7 +545,7 @@ impl Credentials {
|
||||
let res = sqlx::query!(
|
||||
"
|
||||
SELECT
|
||||
uuid, active, username, access_token, refresh_token, expires
|
||||
uuid, active, username, access_token, refresh_token, expires, account_type
|
||||
FROM minecraft_users
|
||||
"
|
||||
)
|
||||
@@ -537,6 +565,7 @@ impl Credentials {
|
||||
.single()
|
||||
.unwrap_or_else(Utc::now),
|
||||
active: x.active == 1,
|
||||
account_type: x.account_type,
|
||||
};
|
||||
|
||||
async move {
|
||||
@@ -572,14 +601,15 @@ impl Credentials {
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO minecraft_users (uuid, active, username, access_token, refresh_token, expires)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
INSERT INTO minecraft_users (uuid, active, username, access_token, refresh_token, expires, account_type)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
ON CONFLICT (uuid) DO UPDATE SET
|
||||
active = $2,
|
||||
username = $3,
|
||||
access_token = $4,
|
||||
refresh_token = $5,
|
||||
expires = $6
|
||||
expires = $6,
|
||||
account_type = $7
|
||||
",
|
||||
uuid,
|
||||
self.active,
|
||||
@@ -587,6 +617,7 @@ impl Credentials {
|
||||
self.access_token,
|
||||
self.refresh_token,
|
||||
expires,
|
||||
self.account_type,
|
||||
)
|
||||
.execute(exec)
|
||||
.await?;
|
||||
@@ -649,6 +680,7 @@ impl Serialize for Credentials {
|
||||
ser.serialize_field("refresh_token", &self.refresh_token)?;
|
||||
ser.serialize_field("expires", &self.expires)?;
|
||||
ser.serialize_field("active", &self.active)?;
|
||||
ser.serialize_field("account_type", &self.account_type)?;
|
||||
ser.end()
|
||||
}
|
||||
}
|
||||
|
||||
64
packages/assets/icons/elyby-icon.svg
Normal file
64
packages/assets/icons/elyby-icon.svg
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="10mm"
|
||||
height="10mm"
|
||||
viewBox="0 0 10 10"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
inkscape:version="1.4.2 (ebf0e940, 2025-05-08)"
|
||||
sodipodi:docname="elyby-icon.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#eeeeee"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#505050"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:zoom="20.48"
|
||||
inkscape:cx="13.891602"
|
||||
inkscape:cy="18.09082"
|
||||
inkscape:window-width="1776"
|
||||
inkscape:window-height="1236"
|
||||
inkscape:window-x="244"
|
||||
inkscape:window-y="25"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs1" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<rect
|
||||
style="fill:#00c600;stroke-width:0.264999;paint-order:markers fill stroke;fill-opacity:1"
|
||||
id="rect1"
|
||||
width="10"
|
||||
height="10"
|
||||
x="0"
|
||||
y="0"
|
||||
rx="1"
|
||||
ry="1" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:9.61119px;font-family:Arial;-inkscape-font-specification:'Arial, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke-width:0.80219;paint-order:markers fill stroke"
|
||||
x="1.0449646"
|
||||
y="9.1731787"
|
||||
id="text1"
|
||||
inkscape:label="text1"
|
||||
transform="scale(1.1466469,0.87210806)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan1"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:9.61119px;font-family:Arial;-inkscape-font-specification:'Arial, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#ffffff;fill-opacity:1;stroke-width:0.802193"
|
||||
x="1.0449646"
|
||||
y="9.1731787">E</tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
@@ -89,6 +89,7 @@ import _PirateIcon from './icons/pirate.svg?component'
|
||||
import _MicrosoftIcon from './icons/microsoft.svg?component'
|
||||
import _PirateShipIcon from './icons/pirate-ship.svg?component'
|
||||
import _AstralRinthLogo from './icons/astralrinth-logo.svg?component'
|
||||
import _ElyByIcon from './icons/elyby-icon.svg?component'
|
||||
|
||||
// [AR] Feature. Exports
|
||||
|
||||
@@ -96,6 +97,7 @@ export const PirateIcon = _PirateIcon
|
||||
export const MicrosoftIcon = _MicrosoftIcon
|
||||
export const PirateShipIcon = _PirateShipIcon
|
||||
export const AstralRinthLogo = _AstralRinthLogo
|
||||
export const ElyByIcon = _ElyByIcon
|
||||
|
||||
// Skin Models
|
||||
export { default as ClassicPlayerModel } from './models/classic-player.gltf?url'
|
||||
|
||||
Reference in New Issue
Block a user